Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. cURL and Qt Project
QtWS25 Last Chance

cURL and Qt Project

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 4 Posters 15.8k Views
  • 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.
  • G ganeshkbhat

    @mrjj I have now been able to compile the libcurl.dll.a file into the lib folder and used a library importer to create the library dependency. Now the -lcurl error is gone. But it still gives undefined errors. What declaration have I gone wrong at? Error is >>> :-1: error: undefined reference to _imp__curl_easy_init' and error are there for other curl functions as well.

    This is my import :
    #include <curl/curl.h>

    This is my code within my widget constructor

    CURL *curl;
    CURLcode res;

      curl = curl_easy_init();
      if(curl) {
          curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
          curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
          res = curl_easy_perform(curl);
          if(res != CURLE_OK){
              qWarning("curl_easy_perform() failed: \n");
          }
        curl_easy_cleanup(curl);
    
    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #7

    @ganeshkbhat
    Hi
    Try to post the .pro file and the output in Creators compiler output panel
    It stills sounds like its not linking. There must be errors somewhere.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      ganeshkbhat
      wrote on last edited by ganeshkbhat
      #8

      QT += core gui
      QT += quickcontrols2

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

      TARGET = APITester
      TEMPLATE = app

      DEFINES += QT_DEPRECATED_WARNINGS

      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000

      SOURCES += main.cpp
      mainwindow.cpp
      apitab.cpp \

      HEADERS += mainwindow.h
      apitab.h \

      FORMS += mainwindow.ui
      apitab.ui \

      DISTFILES +=

      RESOURCES +=

      INCLUDEPATH +=

      LIBS +=

      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/vendor/curl/lib/ -llibcurl.dll
      else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/vendor/curl/lib/ -llibcurl.dlld
      else:unix: LIBS += -L$$PWD/vendor/curl/lib/ -llibcurl.dll

      INCLUDEPATH += $$PWD/vendor/curl/include \

      DEPENDPATH += $$PWD/vendor/curl/include

      win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/vendor/curl/lib/libcurl.dll.a
      else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/vendor/curl/lib/libcurl.dlld.a
      else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/vendor/curl/lib/libcurl.dll.lib
      else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/vendor/curl/lib/libcurl.dlld.lib
      else:unix: PRE_TARGETDEPS += $$PWD/vendor/curl/lib/libcurl.dll.a

      ==========================

      The folder structure is :

      projectfolder/
      file.cpp (and others)
      file.h
      main.cpp
      vendor/
      vendor/curl/
      vendor/curl/include/
      vendor/curl/include/curl.h (and others)
      vendor/curl/lib/
      vendor/curl/lib/libcurl.dll.a

      Errors are follow (one of them is. Its one of the functions curl exposes) :

      undefined reference to _imp__curl_easy_init()'

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #9

        Hi
        Sometimes you need to use the .lib file if using visual studio.
        what compiler ?
        Also i hope you compiled all of curl yourself.

        try with
        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/vendor/curl/lib/ -lcurl.dll
        ( that is remove the lib start of the name. here.)
        make release build.

        Sorry its hard to offer more input without the compiler output :)

        I think its nearly correct. path seems fine etc.

        1 Reply Last reply
        1
        • G Offline
          G Offline
          ganeshkbhat
          wrote on last edited by
          #10

          Hmm.... seems like an issue here. I am actually doing a release build and win32:CONFIG(release, debug|release): LIBS += -L$$PWD/vendor/curl/lib/ -lcurl.dll does not work. I have created a new project with just one file and the curl functions and seems it is still giving the same error.

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

            Hi and welcome to devnet,

            You don't link to .dll files.

            Note that you haven't answered @mrjj'question: which compiler are you using ?

            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
            1
            • G Offline
              G Offline
              ganeshkbhat
              wrote on last edited by
              #12

              I was using mingw and cygwin compiler. I sat the whole night figuring out what issue was and found that it was the path "resolution" issue as mrjj pointed out.

              Here is what resolved my issue for developers who face the issue of External Library not linking correctly to a QT project in windows:

              1. I added the .lib / .dll.a file with full path (from C:) in .pro
              2. I added the include full path (from C:) in .pro
              3. I added the curl.exe and libcurl.exe in the release folders along with other dependency .dlls

              Detailed steps:

              1. Instead of the relative path, I gave the actual full path to library file in the .pro file and it resolved my issue. Here are the file paths I added.
                C:\git\QT\APITester\vendor\curl\lib\libcurl.dll.a or C:\git\QT\APITester\vendor\curl\lib\libcurl.lib and

              2. I added the include full path: C:\git\QT\APITester\vendor\curl\include

              3. I added the curl.exe and libcurl.dll in the release folder (main folder) with other dependency .dlls of QT and created a release build.

              The above steps work as well for debug but you have to have dlld files there for curl there

              I do not know what config settings are getting messed up for this issue to happen. And most of all such linking issues with third party libraries are not documented well. One of the biggest issues of C++ community and adoption is the project set up documentation and project deployment documentation is not good.

              This community saved me here. Thanks all for the effort and support. Thanks to @mrjj and @SGaist who spent time to answer my questions.

              1 Reply Last reply
              2
              • thamT Offline
                thamT Offline
                tham
                wrote on last edited by
                #13

                One of the biggest issues of C++ community and adoption is the project set up documentation and project deployment documentation is not good.

                I share your pain, but this is not just the problem of c++, recently I found the same issue with those deep learning libraries written by python, the truth is, many developers do not care as long as their libs work on linux.

                May I ask you why you refuse to use the network modules provided by Qt5?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  ganeshkbhat
                  wrote on last edited by
                  #14

                  @tham
                  May I ask you why you refuse to use the network modules provided by Qt5?
                  The network modules of QT is good! I can say that looking at the class documentation though I am a beginner with QT. I needed time tracking based results for network requests like this http://i63.tinypic.com/21ls83l.png which is quite cumbersome and may be not possible with the QT network module.

                  @SGaist
                  You can link external .dll files for your point You don't link to .dll files. . I was able to do that for an external library linking with QT using sqlite3.dll and it worked fine. Not sure why you referred that.

                  @tham
                  recently I found the same issue with those deep learning libraries written by python, the truth is, many developers do not care as long as their libs work on linux.
                  True. I found that. But QT is not like that. QT is a commercial product for sale. Thats what makes a product/concept mature and marketable.

                  I definitely believe there needs to be better documentation on minor issues and tweaks for product like QT. Frankly, its one of the best I found for C++ UI Controls and the performance is... good for the features it provides.

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

                    Usually when that works, it's because you have the matching .lib files (in the case of Visual Studio) in the same folder as your .dll files and the linker picks that one up.

                    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
                    1
                    • G Offline
                      G Offline
                      ganeshkbhat
                      wrote on last edited by
                      #16

                      Ah no. I am using mingw compiler and qtcompiler with mingw

                      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