libcurl on Windows with Visual Studio 2005
July 27thDeveloping on Windows can be a real pain. I spent a few hours looking around for an easy way to perform simple HTTP GET calls inside vanilla win32 code. What a pain. WinINet is a disaster and WinHTTP is not much better. It also isn’t supported on all the versions of Windows we target, argh.
It turns out that you can get libcurl [one of favorite libraries] to work on Windows within Visual Studio. Here is a quick overview how to make it happen with the 7.16.4 release.
Download the source and load lib\curllib.vcproj in Visual Studio
In curllib project properties->Configuration Properties->C/C++->Code Generation->Runtime Library change the value to Multi-Threaded /MT [assuming a release build] so it correctly builds as a static library
Then in the project you intend to use libcurl - in the preprocessor section, define CURL_STATICLIB and add the curl include directories
In the linker section add curllib.lib, ws2_32.lib, winmm.lib
Prosper
For good measure, I’ve uploaded a release build of this lib that you can link to in your project [skip steps 1 and 2]




August 8th, 2007 at 10:00 pm
I spent FOREVER working on this. Thank you so much for helping me out by writing this blog post.
August 29th, 2007 at 4:16 pm
Would you happen to know how to take this one step further and build with libssh2 for ssh support — for sftp?
August 29th, 2007 at 4:23 pm
Haven’t explored that. I might update this with instructions on how to build in SSL support though.
September 17th, 2007 at 2:47 am
Well, it’s easy to build the lib, but I still don’t see how to solve the linker issues in my project which uses the lib.
unresolved externals:
curl_easy_cleanup
curl_easy_perform
curl_easy_setopt
curl_easy_init
…
…
September 17th, 2007 at 2:12 pm
@Natko - Make sure you link the library. Those externals are in curllib.lib
September 22nd, 2007 at 1:48 pm
Thanks a lot! Your post was a great help.
October 28th, 2007 at 6:08 pm
[...] magnetk.com writes about how to build a recent libcurl with visual studio 2005 [...]
November 28th, 2007 at 10:24 am
Hi there, great work you’ve done :-) ….. this was a real pain in the ass for me.
January 9th, 2008 at 7:02 am
Thanks a bunch! I had hard time with this, but your post helped a lot!
March 26th, 2008 at 11:19 am
[...] ugly and verbose. Another option, WinHTTP, didn’t work on Windows 2000 GM. We ended up using libCURL. It was a ridiculous and frustrating waste of [...]
May 6th, 2008 at 2:42 am
Just got cURL 7.18.1 source and cURL.NET binding source (last build 2005) and was going to try to rebuild the .NET binding project with VS2005, then VS2008/.NET3. I’m a C# guy, not qualified to work with C++ but I did update and publish another OSS project so I’m not totally clueless. Anyway, I packed it up pretty quickly: There are environment vars and tweaks to configs, libs to include and other packages to include and update (OpenSSL, zLib…). Stuff like zLib hasn’t been updated in a couple years and some help pages suggest linking in stuff I’ve never heard of. No, I’m afraid this isn’t work for the lightweight. I’m not looking for a fish but a fishing pole - can anyone suggest some reading that will lead me to being able to create updated DLL’s so that anyone can simply “reference n run” their cURL-powered apps using any .NET/CLR language? I’d be happy to maintain some of this stuff but I don’t have a clue how to do the initial bundle. TYVM