Installing curl library for Visual Studio 2015 (vs14)

Hi guys,
I was trying to install the curl library for the last 2 days, and I get nothing...
The instructions in the curl page are from 10 years ago, I read a lot of forums, but I didn't found anything for Visual Studio 2015, some for 2013, but don't work (building errors and so...)
I tried to add to my project, but I got errors, and after search in forums, I tried to find curllib.lib, that seems that is needed, and I couldn't find, so I think have to install in some way the library first right?
I'm noob with C++ and external libs, please help me with this....there are some way, easy to understand (please), to solve this?
Actually the documentation is very up to date, it's just that developers are notorious for not providing build instructions.

It looks like the GitHub source repo has a CMakeLists.txt file:
https://github.com/bagder/curl

Have you tried building with cmake -G "Visual Studio 14 2015" or cmake -G "Visual Studio 14 2015 Win64"?

EDIT: There's a winbuild folder with instructions in it, have you tried that?
Last edited on
I followed the instructions from winbuild/BUILD.WINDOWS.txt
- I opened the developer command prompt for VS2015
- In the prompt, I go to curl/winbuild directory.
- I executed "nmake /f Makefile.vc mode=dll VC=14" (dll mode is wright?)
- Seems like all goes well. Generates a builds/ directory, with 3 subdirectories in it. 1 of this subdirectories (libcurl-vc14-x86-release-dll-ipv6-sspi-winssl/), have "include/" and "lib/" directories in it.

Then I go to my project options:
- In VC++ directories -> In "Include Directories" I add the "include/" path
                                 -> In "Librarie Directories" I add the "lib/" path
- In linker / General -> In "Additional Library Directories" I add the "lib/" path too


Then I got this errors:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1188,5): warning
MSB8012: TargetPath(C:\Users\Selmo\Documents\Visual Studio 2015\Projects\ParsePlayers\Debug\ParsePlayers.exe)
does not match the Linker's OutputFile property value (). This may cause your project to build incorrectly.
To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match
the value specified in %(Link.OutputFile).
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
1>IoFile.exe : fatal error LNK1120: 5 unresolved externals
You have to explicitly link to the correct .lib files, you can't just point your compiler to the directory where they are and expect it to magically try combinations until one works.

Your debug mode should link to the debug libraries, and your release mode should link to the release libraries.
You are not building libcurl in debug mode, are you ?

The official way to build libcurl is with CMake.
http://www.cmake.org/
Last edited on
Ok finally I got it :-D :-D
First of all thanks a lot guys, you helped me a lot.
I will write the things I did, maybe this is easy for most of you, but could be helpfull for someone like me :-)

Added to wrote above:
- As you are well saying, I built the release folders, and I was trying to run in debug mode. I changed to release mode in Visual Studio, and added too the include/ and lib/ path in properties as same as i did before(take care with this. Project options changes between debug and release mode).
- I added too in properties -> Linker -> Additional dependencies:
libcurl.lib

- I copied into my project folder the file "libcurl.dll" (from the bin folder, the other one than include/ and bin/)

- Finally take care to select in Visual studio the same bit size (32 bits / 64 bits) than the version from curl that you downloaded.

This blog answer was helpfull for me:
stackoverflow.com/questions/30288415/curl-with-visual-studio-2013

And the basic code that I'm executing is:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
	CURL *curl;
	CURLcode res;

	curl = curl_easy_init();
	if (curl) {
		curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.co.uk/");
		res = curl_easy_perform(curl);

		curl_easy_cleanup(curl);
	}


	getchar();
	return 0;
}
Topic archived. No new replies allowed.