1
votes

My code:

#include <curl/curl.h>
...
CURL *curl;
CURLcode res;

curl_global_init(CURL_GLOBAL_DEFAULT);

curl = curl_easy_init();
if(curl)
{
    curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com/");

    res = curl_easy_perform(curl);
    if(res != CURLE_OK)
    {
        const char *error = curl_easy_strerror(res);
        wchar_t *errorw;
        mbtowc(errorw, error, sizeof(error));
        MessageBox(Application->Handle, L"Test", errorw, 0);
    }

    curl_easy_cleanup(curl);
}
curl_global_cleanup();
...

When I'm trying to compile my program with libcurl, I'm getting this errors:

[ilink32 Error] 
Error: Unresolved external 'WSAIoctl' referenced from ..\LIBCURL.LIB|easy  
... '_Curl_resolver_init' referenced from ..\LIBCURL.LIB|url  
... '_Curl_resolver_cleanup' referenced from ..\LIBCURL.LIB|url  
... '_Curl_set_dns_servers' referenced from ..\LIBCURL.LIB|url  
... '_Curl_resolver_wait_resolv' referenced from ..\LIBCURL.LIB|connect  
... '_Curl_resolver_cancel' referenced from ..\LIBCURL.LIB|url  
... '_Curl_resolver_getaddrinfo' referenced from ..\LIBCURL.LIB|hostasyn  
... '_Curl_resolver_is_resolved' referenced from ..\LIBCURL.LIB|hostip  
... '_Curl_resolver_getsock' referenced from ..\LIBCURL.LIB|multi  
... '_Curl_resolver_global_init' referenced from ..\LIBCURL.LIB|easy  
... '_Curl_resolver_global_cleanup' referenced from ..\LIBCURL.LIB|easy  
... '_Curl_resolver_duphandle' referenced from ..\LIBCURL.LIB|easy

include/curl copied to C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\include
lib/libcurl.lib and libcurl_imp added to project via Project->Add...

How to fix this error?

EDIT:
When I'm compiling just with libcurl_imp.lib, all is fine, but programm needs libcurl.dll.

1

1 Answers

0
votes

Even though you have copied the library into your build environment you need to explicitly tell it to link the library to your application.

The embarcadero website has a nice page on how to configure your project settings to link additional ilbraries.




For the new error you get after using the above solution you need to make some additional changes. First you will need to link the Winsock library called Ws2_32.lib in order to use WSAIoctl. It's a Windows library so it should already be installed in your development environment.

Once you've added that library you will need to double check the libcurl configuration to make sure the proper calls are compiled into the library. You will need to rebuild the library (or download a precompiled version) in order to get these missing function calls. When you build the library that at least USE_ARES and CURLRES_ASYNCH have been added to the predefined symbols settings of the preprocessor. You will also want to make sure the following additional symbols are defined.