error LNK2019: unresolved external symbol __imp_curl_global_init referenced in function

When building a project that links to libcurl, you may get these errors:

error LNK2019: unresolved external symbol __imp_curl_global_init referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_global_cleanup referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_easy_setopt referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_easy_cleanup referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_multi_init referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_multi_add_handle referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_multi_remove_handle referenced in function  xxx
error LNK2019: unresolved external symbol __imp_curl_multi_cleanup referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_multi_info_read referenced in function xxx
error LNK2019: unresolved external symbol __imp_curl_multi_socket_action referenced in function  xxx
error LNK2019: unresolved external symbol __imp_curl_multi_setopt referenced in function xxx
 error LNK2019: unresolved external symbol __imp_curl_multi_assign referenced in function xxx

This is because the project links to wrong libcurl. From the prefix of the referenced function names: __imp, we can tell your project is configured to link to the dynamic import lib of libcurl. Now, the most possible reason is that you are now linking to the static lib of libcurl. If you downloaded the prebuilt libcurl, and configured your project with(CMake option):

-DCURL_LIBRARY=C:\curl-7.87.0-win64-mingw\lib\libcurl.a

you will encounter the mentioned errors because libcurl.a is a static library. The correct configuration option is:

-DCURL_LIBRARY=C:\curl-7.87.0-win64-mingw\lib\libcurl.dll.a

libcurl.dll.a is a dynamic import lib that contains the functions __imp_xxxx.

Leave a Reply