I have linked curl statically before some time ago, but I can't remember how I did it. I've followed every instruction of every StackOverflow question, youtube video, curl.haxx archive and more. But I still get unresolved externals when trying to launch my program. I built statically folliwing the instructions in winbuild of curl-7.57.0.
What I've done:
Built using nmake, made a mode=static DEBUG=yes and mode=static DEBUG=no
Defined STATIC_CURLLIB
Added include and lib directory to my MSVC 2017 Project
And includes/linked as needed. (libcurl_a_debug.lib in Additional Libraries)
#define CURL_STATICLIB
#include <curl\curl.h>
int main()
{
/* Our app's entry point. Main function */
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
Errors:
1 2 3 4 5
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_strerror referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function _main