Getting LibCurl to work with Visual Studio 2013

A lot of these instructions are out of date because they recommend the win32-ssl-devel-msvc package for curl, which no longer exists.

The following instructions allow you to build libcurl using only:

  • Visual Studio 2013
  • curl generic source tarball (tested on curl 7.44.0).

A. Build libcurl static library

  1. Download the latest curl generic source from: http://curl.haxx.se/latest.cgi?curl=tar.gz
  2. Extract the source to a local directory (we’ll be using C:\libcurl)
  3. Open a command prompt
  4. "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat" To initialize your VC environment variables (adjust your VS 2013 installation directory as needed)
  5. cd C:\libcurl\winbuild
  6. nmake /f Makefile.vc mode=static VC=12
  7. The build should appear in C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl

B. Link Against libcurl in Visual Studio

  1. In Visual Studio, right click your project in Solution Explorer, then click “Properties”
  2. Configuration Properties > C/C++ > General > Additional Include Directories: add C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\include
  3. Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions: add CURL_STATICLIB
  4. Configuration Properties > Linker > General > Additional Library Directories: add C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib
  5. Configuration Properties > Linker > Input > Additional Dependencies: add libcurl_a.lib

C. Call libcurl from Your Project

The following sample shows a call to libcurl:

#include "stdafx.h"

#include <curl/curl.h>

void main(int argc, char* argv[])
{
    CURL *curl = curl_easy_init();
    if (curl) printf("curl_easy_init() succeeded!\n"); 
    else fprintf(stderr, "Error calling curl_easy_init().\n");
}

Leave a Comment