How to Build and Use Libcurl with VS2015 on Windows

Libcurl is a free, open source library for transferring data. It supports various protocols include FTP, FTPS, HTTP, HTTPS, GOPHER, TFTP, SCP, SFTP, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3, RTSP, and RTMP. I’ve been looking for a cross-platform HTTP library for my project, and libcurl seems to be the best choice.

Libcurl Download

The latest curl version is 7.45.0:

How to Build and Distribute Libcurl with Visual Studio 2015 on Windows

Run Visual Studio Command Line Tool:

Visual Studio Command Line Tool

Change directory to winbuild.

To distribute your application, you can force nmake to link in the static Microsoft’s C RunTime (CRT) by passing RTLIBCFG=static.:

Set RTLIBCFG=static

Then build static libcurl with the following command:

nmake /f mode=static VC=14 MACHINE=x64 DEBUG=no

The generated libraries and header files are located at ../builds.

libcurl build

Create a new win32 project in Visual Studio 2015 and copy all relevant header files and static libraries into the project.

Write a simple test:

#include "stdafx.h"
#include "libcurl/include/curl/curl.h"

#ifdef _DEBUG
#pragma comment(lib, "libcurl/lib/libcurl_a_debug.lib")
#pragma comment(lib, "libcurl/lib/libcurl_a.lib")

int main()
	CURL *curl = curl_easy_init();
	if (curl) {
		CURLcode res;
		curl_easy_setopt(curl, CURLOPT_URL, "");
		res = curl_easy_perform(curl);
	printf("Press any key to continue\n");
    return 0;

When building the project, you may see the error - curl.obj : error LNK2019: unresolved external symbol:

libcurl error

To fix the error, add the macro CRUL_STATICLIB to preprocessor:

curl static lib

Now you can successfully build your project.

One more thing! Do not forget to change Runtime Library to Multi-threaded(/MT):

runtime library mt

Test the curl app with

curl test

Source Code

Search Blog Posts