News

Building libcurl using Visual Studio 2005

« Back to news

It’s actually really simple and in fact I am posting this for people like myself who are in a bit too much of a hurry and miss the simple things. Everything you need comes with the zip file that you can download here:
http://curl.haxx.se/download.html

This article is divided into the following sections:

  1. Basic build
  2. Matching up C runtimes
  3. Debug build
  4. Troubleshooting
  5. Contact

1. Basic build

Once you have that do the following:

  1. Extract it.
  2. Edit the Makefile in the root directory and find the line that says "VC=vc6" and change it to "VC=vc8".
  3. Look at the file named INSTALL in the docs directory. Scroll down to where it says "MSVC from command line" and read through at least the first paragraph.
  4. If like me you just want a basic DLL, instead of running "nmake vc", run "nmake vc-dll" which will build a dynamic release version of the library and place the lib and dll in the root directory. Note: You should probably also ensure that the C runtime used in your project matches that used with libcurl. More on this below.
  5. To see what other options are available, look in the Makefile and do a search for "vc-all". Underneath you should a whole load of different build types.

2. Matching up C runtimes

In your visual studio project go to your project properties -> Configuration properties -> C/C++ -> Code Generation. You might see something like: Multi-threaded Debug DLL (/MDd). As you can see to match up the runtimes libcurl must be built as a DLL in debug mode. You can ignore the Multi-threaded part as there is no way to build single threaded.

There is one snag, to build a debug DLL there are a few modifications that need to be made.

3. Debug build

If you want to do a debug build it’s slightly trickier because things seem to be a bit broken. First you need to add a debug build option in the main Makefile. I added the following under vc-dll:

vc-dll-debug:
cd lib
nmake /f Makefile.$(VC) cfg=debug-dll
cd ..\src
nmake /f Makefile.$(VC) debug cfg=debug-dll

You then need to edit lib\Makefile.vc8 and change the "release dynamic library" option to:

# release and debug dynamic library
!IF "$(CFG)" == "release-dll" || "$(CFG)" == "debug-dll"
LINKLIBS = libcurl_imp.lib
LINKLIBS_DEBUG = libcurld_imp.lib
!ENDIF

To use the option just go back to your root directory and use "nmake vc-dll-debug".

4. Troubleshooting

Q: I get the error message: "Ordinal 55 can not be found in zlib1.dll"
A: You’re probably using a pre-built version of libcurl, roll your own using the above instructions or try and find a different binary.

Q: The procedure entry point WSAPoll could not be located in the dynamic link library WS2_32.dll.
Q: I get errors such as "error LNK2019: unresolved external symbol __imp__ldap_unbind_s referenced in function _Curl_ldap libcurl.lib " when building my project.
Q: I get errors such as "error LNK2001: unresolved external symbol __imp__curl_easy_init" when building my project.
A: Don’t bother trying to build it using the IDE, just use the Makefile from the command line as explained above.

Q: You get warnings while building such as:
cl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'EHsc' instead of 'GX'
cl : Command line warning D9002 : ignoring unknown option '/YX'
A: Ensure you have change the "VC=vc6" line in the Makefile to "VC=vc8"

Q: Something else
A: See the Libcurl FAQ.

5. Contact

If you have any questions, comments etc please feel free to email me. All my details can be found here.

Hosted by www.Geocities.ws

1