You need to define CURL_STATICLIB
when including curl.h, otherwise the compiler will think that you are trying to link against the dynamic version of the libcurl library.
If you examine curl.h, you can see the following lines:
/*
* Decorate exportable functions for Win32 DLL linking.
* This avoids using a .def file for building libcurl.dll.
*/
#if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB)
#if defined(BUILDING_LIBCURL)
#define CURL_EXTERN __declspec(dllexport)
#else
#define CURL_EXTERN __declspec(dllimport)
#endif
#else
You can see that by default, every function is declared with the __declspec(dllimport)
convention, which add those _imp__
prefixes on symbol names.
So you need to define CURL_STATICLIB in your CMakeLists.txt, like this:
add_definitions(-DCURL_STATICLIB)