I know this is programming questions but I'm just frustrated trying to figure out what I'm doing wrong..
I'm using visual studio 2010 and followed all the steps here: http://curl.haxx.se/libcurl/c/visual_studio.pdf
When I try to compile my solution I keep getting this error:
1>------ Build started: Project: LibCurl, Configuration: Debug Win32 ------
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _main
1>C:\Users\Kyle\Documents\Visual Studio 2010\libcurl\VisualStudio\LibCurl\Debug\LibCurl.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Source:
// LibCurl.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#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://google.com");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
I ran into a similar issue - found that I was referencing the 64-bit location of libcurl.lib. Changed the link directory to the 32-bit location and the project compiled perfectly.
Looks like the libraries are not being successfully linked. Ensure the library directory is set to include the full path to the libcurl dll. Also make sure this library is actually added to your project.
After many ideas and configurations, I solved the problem adding this:
#pragma comment(lib, "lib/libcurl_a.lib")
where
libcurl_a.lib
is the name of the curl lib file andlib
is the folder which contains it.I've been using static version of libcurl, and to link my program against it properly, I had to add definition:
CURL_STATICLIB
to build configuration of my project.
I had the same problem. I wrote how I finally was able to make CurlLib works, here: http://quantcorner.wordpress.com/2012/04/08/using-libcurl-with-visual-c-2010/ if you wish to have a look. Good luck!
Besides defining
CURL_STATICLIB
, for me it was also necessary to link the following dependencies (includinglibcurl.lib
orlibcurld.lib
):Ws2_32.lib
Wldap32.lib