QtCreator and cURL - final showdown.



  • Hi.
    I read a hundred sites.
    I try to run libraries third day.
    But I can't run my code.

    I work on Windows 7 64bit
    "Tutorial":http://howtofix.pro/tutorial-libcurl-on-qt-creator-with-mingw/
    "Qt 5.3.1 for Windows 32-bit (MinGW 4.8.2, OpenGL) ":http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe
    "Win - MinGW64 7.34.0 devel SSL SSH Günter Knauf":http://curl.haxx.se/gknw.net/7.34.0/dist-w64/curl-7.34.0-devel-mingw64.7z

    .pro file:
    @TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle

    SOURCES += main.cpp

    INCLUDEPATH += C:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\include\curl
    LIBS += -LC:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\lib64 -lcurl
    #LIBS += -LC:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\lib64\libcurldll.a -this also didn't work
    @

    .cpp file:
    @#define CURL_STATICLIB
    #include <stdio.h>
    #include <curl.h>
    #include <easy.h>
    #include <string>

    size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    size_t written;
    written = fwrite(ptr, size, nmemb, stream);
    return written;
    }

    int main(void) {
    CURL *curl;
    FILE *fp;
    CURLcode res;
    char *url = "http://localhost/aaa.txt";
    char outfilename[FILENAME_MAX] = "C:\bbb.txt";
    curl = curl_easy_init();
    if (curl) {
    fp = fopen(outfilename,"wb");
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    fclose(fp);
    }
    return 0;
    }
    @

    Always
    "error: undefined reference to curl_easy_init'" "error: undefined reference tocurl_easy_setopt'"
    "error: undefined reference to `curl_easy_perform'"

    I add and link libraries.
    I add "#define CURL_STATICLIB"
    I copy libcurl dll files to Qt project Release/Debug
    but it didn't work.

    Please help.


  • Moderators

    Your libraries are binary incompatible: you are trying to link a 64 bit library to a 32 bit program. That will not work. Arhcitectures and compilers must match.



  • I tried compile program with MinGW64. Win32 - MSVC also didn't work.
    I don't know, why there is no cURL MinGW32.


  • Moderators

    Compile curl yourself, using the compiler from Qt package, then compile your application using the same compiler.



  • I find cURL MinGW32 - didn't work. The same fail.
    I don't know, how to compile this. It is difficult for me.
    I must download Source Archives - curl 7.37.1.zip, yes?
    I need to use QtCreator or only MinGW and command line?


  • Moderators

    Then maybe easier option is to download the 64 bit Qt package?



  • Yes, but MinGW is only in version Qt 32b. I don't know why.

    Erlier I have a problem with version Qt VS, programs didn't compile, so I download MinGW. But some problems still are.


  • Moderators

    I'm so happy to be developing on Linux ;-) Problems like that are pretty much unheard of here.

    Maybe there were problems with MinGW64 on Windows, so they have dropped the package, I don't know. You can try compiling Qt yourself, although it's not so easy on Windows.



  • So, now:
    Qt, MinGW and cURL are for Windows 32-bit, and problem is not solved. Why?
    I need to add some packages?
    Do I something wrong?


  • Moderators

    They might have been compiled using different version of MinGW. Some versions are not compatible with one another...

    or something else is wrong. One thing is certain: the error you are getting is a linker error, so there is no bug on the C++ side.



  • Problem solved, but not completly.
    All libcurl sources I moved to project folder, and I add:
    @INCLUDEPATH += C:...\curl-7.34.0-devel-mingw32\include
    LIBS += C:...\curl-7.34.0-devel-mingw32\lib\libcurldll.a
    LIBS += C:...\curl-7.34.0-devel-mingw32\lib\libcurl.a
    @
    But programs exited with code -1073741515, what is the same as 0xC0000135 -> problem with dependency...

    The Fight Continues...


  • Lifetime Qt Champion

    Hi,

    You're application is probably not finding the libcurld dll. In Qt Creator go to Project -> run -> PATH and add the path to the folder containing the curl dll



  • I added path the libcurl dll (to Projects -> Run -> Run Environment -> Path), but nothing changes.
    Still " programs exited with code -1073741515"


  • Moderators

    What happens when you run with the debugger?



  • "The gdb process terminated unexpectedely (code 0)"
    "Cannot continue debugged process: The program is not being run"
    and
    "During startup program exited with code 0xc0000135"

    Even when I close the terminal window, program is still running (when I want to quit Qt I get a message "Do you want to force quit untitled.exe?)



  • I installed Qt Creator 64 bit, Visual Studio 2013, cURL 64bit, and I have
    "Cannot obtain a handle to the inferior: The parameter is incorrect."
    So I cleaning project, and again
    "exited with code -1073741515"

    Files are now in release folder
    @INCLUDEPATH += C:\Users...\build-one-Qt_64bit-Release\curl-7.34.0-devel-mingw64\include
    LIBS += C:\Users...\build-one-Qt_64bit-Release\curl-7.34.0-devel-mingw64\lib64\libcurldll.a
    LIBS += C:\Users...\build-one-Qt_64bit-Release\curl-7.34.0-devel-mingw64\lib64\libcurl.a
    @

    Any suggestions?

    Edit:
    Qt ask about "curl.lib", so I find it and copy to lib files.
    Now Qt want "curldll.lib" and these file I can't find.
    Why are they needed? .dll files are not enough?



  • Finally, problem solved.
    I run untitled.exe form explorer, and message shown, which dll is necessary.
    So I download some dll's and it's work.
    Thanks for response.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.