I am trying to use visual studio 2015 to statically link a small test curl program, however i cannot get it to link properly.
I used this batch file to compile curl which worked successfully https://github.com/blackrosezy/build-libcurl-windows
I then copied the libcurl directory into my project directory and my code is the following
#include "stdafx.h"
#include "libcurl/include/curl/curl.h"
#pragma comment(lib, "libcurl/lib/static-debug-x64/libcurl_a_debug.lib")
#define CURL_STATICLIB
int main()
{
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
printf("Press any key to continue\n");
getchar();
return 0;
}
However no matter what i do i cannot get my linker to grow out of doing this:
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_global_init referenced in function main
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_global_cleanup referenced in function main
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function main
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_easy_setopt referenced in function main
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_easy_perform referenced in function main
1>CurlTest.obj : error LNK2019: unresolved external symbol __imp_curl_easy_cleanup referenced in function main
1>U:\Main\Code\CurlTest\x64\Debug\CurlTest.exe : fatal error LNK1120: 6 unresolved externals
I have confirmed all of these paths are valid, and have tried using both debug and release libs, and 32 and 64 bit (With matching settings in visual studio). This will compile with a non-static library, but that's crap as i'd like to just distribute my .exe not dll's as well.
What am i doing wrong here? This is very frustrating, it looks like it's just being childish as from what i've read from similar threads that #define CURL_STATICLIB directive should rectify this behaviour.