Wednesday, April 28, 2010

libcurl on Windows with Visual Studio 2005

Developing 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.

  1.       Download the source and load lib\curllib.vcproj in Visual Studio
  2.       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
  3.       Then in the project you intend to use libcurl – in the preprocessor section, define CURL_STATICLIB and add the curl include directories
  4.       In the linker section add curllib.lib, ws2_32.lib, winmm.lib
  5.       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]

Read more: ExpandDrive
Read more: libcurl.NET

Posted via email from jasper22's posterous