Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QtCreator and cURL - final showdown.
Forum Updated to NodeBB v4.3 + New Features

QtCreator and cURL - final showdown.

Scheduled Pinned Locked Moved Installation and Deployment
17 Posts 3 Posters 10.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jareq000
    wrote on last edited by
    #1

    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 to curl_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.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jareq000
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

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

          (Z(:^

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jareq000
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

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

              (Z(:^

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jareq000
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  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.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jareq000
                    wrote on last edited by
                    #9

                    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?

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #10

                      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.

                      (Z(:^

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jareq000
                        wrote on last edited by
                        #11

                        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...

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          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

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jareq000
                            wrote on last edited by
                            #13

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

                            1 Reply Last reply
                            0
                            • sierdzioS Offline
                              sierdzioS Offline
                              sierdzio
                              Moderators
                              wrote on last edited by
                              #14

                              What happens when you run with the debugger?

                              (Z(:^

                              1 Reply Last reply
                              0
                              • J Offline
                                J Offline
                                jareq000
                                wrote on last edited by
                                #15

                                "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?)

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  jareq000
                                  wrote on last edited by
                                  #16

                                  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?

                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    jareq000
                                    wrote on last edited by
                                    #17

                                    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.

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved