Linking libcurl statically throws unresolved externals.

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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #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
Last edited on
Looks like you said it's not a debug build, but then you're linking to a debug lib. Is that right?
When building my project as debug I am linking to libcurl_a_debug.lib which was compiled using nmake Makefile.vc mode=static DEBUG=yes
Last edited on
This is still an issue. Note: even if I change from MDd to MTd the errors stay the same.
Topic archived. No new replies allowed.