C++ Compile cURL in Windows

Viewed 47

I'm trying to build a C++ application with the curl.h library, I'm using the following implementation:

#include <curl/curl.h>
int main(void)
{
    CURL *curl;
    CURLcode res;
    curl_global_init(CURL_GLOBAL_ALL);

    curl = curl_easy_init();
    if (curl)
    {
        curl_easy_setopt(curl, CURLOPT_URL, "....");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "...");

        res = curl_easy_perform(curl);

        if (res != CURLE_OK)
           fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));

        curl_easy_cleanup(curl);
   }
   curl_global_cleanup();
   return 0;
 }

I've already copied the curl-7.85.0_1-win64-mingw library files into the Mingw folder, but when I compile I'm getting the following message:

C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x16): undefined reference to _imp__curl_global_init' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x1d): undefined reference to _imp__curl_easy_init' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x4a): undefined reference to _imp__curl_easy_setopt' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x68): undefined reference to _imp__curl_easy_setopt' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x76): undefined reference to _imp__curl_easy_perform' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0x8f): undefined reference to _imp__curl_easy_strerror' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0xb9): undefined reference to _imp__curl_easy_cleanup' C:\Users\Teste\AppData\Local\Temp\ccQE8stl.o:SendMsgClient.cpp:(.text+0xc0): undefined reference to _imp__curl_global_cleanup'

These were the commands I used to try to compile:

g++ ./SendMsgClient.cpp -lcurl

g++ -L..\lib\curl\lib64 -I..\lib\curl\include -lcurl ./SendMsgClient.cpp

mingw32-g++ ./SendMsgClient.cpp -lcurl

I can compile on Linux with:

g++ ./SendMsgClient.cpp -lcurl

PS: I don't use any kind of IDE.

0 Answers
Related