Search code examples
cgccmingwlibcurlmingw32

MinGW32-GCC, LibCurl Linking Pro


I am having quite a problem compiling LibCURL with MinGW32-gcc on my pc. I put the files from the LibCURL download "includes", "lib", and "bin" into the corresponding MinGW32 folders. Currently my code is below and it is extremely simple for testing if it worked(Which it is not as I am posting here.)

#include <stdio.h>
#include <curl/curl.h>

int main(int argc, char **argv)
{

    /************************
            Variables
    ************************/

    CURL *curl;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    return 0;
}

Which I then in term compile with the following command line:

mingw32-gcc main.c -lcurl -o compiled.exe --std=c99

That compiler command line is throwing the following error:

C:\Users\Ikaros\AppData\Local\Temp\ccc5ojVE.o:main.c:(.text+0x8e): undefined ref
erence to `_imp__curl_global_init'
collect2.exe: error: ld returned 1 exit status
Press any key to continue . . .

Do you have any recommendation on why this would not be working the way it should?


Solution

  • This is possibly a mismatch of the library to the local architecture ie. MinGW32 versus MinGW64. The download site for libCurl has a prebuilt library for MinGW64 but not MinGW32.