Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Troubles setting up Curl

Troubles setting up Curl

Scheduled Pinned Locked Moved Qt Creator and other tools
curlqt 5.4.2linking
12 Posts 2 Posters 7.5k 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by Chris Kawa
    #2

    Hi, welcome to devnet.

    Instead of the PRE_TARGETDEPS you need to add it to the LIBS variable like so:

    LIBS += -L$PWD/../../../curl-7.40.0-devel-mingw32/lib -lcurl
    

    Notice -L in front of the directory, than a space, -l(lowercase L), name of the library without the "lib" prefix and extension.
    Make sure curl is built using the exact same version of the compiler you're using for your own project.

    R 1 Reply Last reply
    0
    • Chris KawaC Chris Kawa

      Hi, welcome to devnet.

      Instead of the PRE_TARGETDEPS you need to add it to the LIBS variable like so:

      LIBS += -L$PWD/../../../curl-7.40.0-devel-mingw32/lib -lcurl
      

      Notice -L in front of the directory, than a space, -l(lowercase L), name of the library without the "lib" prefix and extension.
      Make sure curl is built using the exact same version of the compiler you're using for your own project.

      R Offline
      R Offline
      RaJiska
      wrote on last edited by
      #3

      Hello, thank you for your answer,

      I took another version of cURL that I compiled with VC12, I then took the file called 'libcurl.lib' and linked it in the .pro file as you suggested:

      LIBS+= -L"C:\Users\Banzai\Desktop\C++\QtPgrm\build-QtPgrm-Desktop_Qt_5_4_2_MSVC2010_OpenGL_32bit-Debug\includes" -llibcurl

      Here is what I get when using 'curl_easy_init();' or any other 'curl_easy*':

      error: LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)

      And yes, it uses the same compiler. Thanks.

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #4

        As I said earlier - skip the lib prefix, i.e. -lcurl not -llibcurl. The linker adds the prefix automatically.

        1 Reply Last reply
        1
        • R Offline
          R Offline
          RaJiska
          wrote on last edited by
          #5

          Oh ok, my apologies.

          Just tried it, however, it doesn't seem to look for the right file.
          Here is the error message Qt threw back:

          LNK1181: cannot open input file 'curl.lib'


          The folder in question contains:

          • curl → directory
          • libcurl.lib → file

          Also tried to rename 'libcurl.lib' to 'curl.lib', and this time, the same error as the one given in my last post appears.

          Thanks for your help.

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #6

            Ah, just spotted another problem - you're using \ in your path. That's an escape sequence. Either change that to / or \\.
            -lcurl is ok, so:

            LIBS += -LC:/Users/Banzai/Desktop/C++/QtPgrm/build-QtPgrm-Desktop_Qt_5_4_2_MSVC2010_OpenGL_32bit-Debug/includes -lcurl
            
            1 Reply Last reply
            0
            • R Offline
              R Offline
              RaJiska
              wrote on last edited by RaJiska
              #7

              Thanks for your help,

              However, it sticks to the same issue (cannot open input file).
              Here is my whole .pro file in case it might be of any help:


              #-------------------------------------------------

              Project created by QtCreator 2015-07-16T18:24:19

              #-------------------------------------------------

              QT += core gui widgets

              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

              TARGET = QtPgrm
              TEMPLATE = app

              QMAKE_LFLAGS += /INCREMENTAL:NO

              SOURCES += main.cpp
              mainwindow.cpp

              HEADERS += mainwindow.h

              FORMS += mainwindow.ui

              LIBS+= -L"C:/Users/Banzai/Desktop/C++/QtPgrm/build-QtPgrm-Desktop_Qt_5_4_2_MSVC2010_OpenGL_32bit-Debug/includes" -lcurl


              Thank you very much.

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by Chris Kawa
                #8

                Are you sure you've got the path correctly? It's unusual that a .lib file would be placed in '.../includes' directory.
                Oh, and after you make any kind of changes in the .pro file be sure to re-run qmake: Build->Run qmake.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RaJiska
                  wrote on last edited by RaJiska
                  #9

                  Yes, I am pretty sure it's in the right directory.
                  Have made several tests to ensure the path is correct,
                  by modifying the -lcurl at the end, here is what I got:

                  • -lcurl → LNK1181: cannot open input file 'libcurll.lib' (the one you advised me)
                  • -llibcurl → LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z) (the one I used)
                  • -llibcurlaa → LNK1181: cannot open input file 'libcurlaa.lib' (it was to see the behavior when searching for known inexisting lib, which is pretty similar to the first case)

                  Thank you.

                  EDIT: And yes, every modifications made in the .pro file is followed by a Run QMake.

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Sorry, I mistook something. It's the MinGw linker that adds the 'lib' prefix, but you're using VS2010 so it indeed should be -llibcurl, not -lcurl. My bad.

                    So it seems the lib is linked but it does not contain the symbol. You can verify this by running from command line dumpbin.exe /exports your/path/to/libcurl.lib > foo.txt and then inspecting foo.txt to see if the symbol is there. dumpbin is part of your VS installation located in <VS dlocation>/VC/bin.

                    If the symbol is there then it means your app's compiler or compilation flags differ from the ones used to build curl.
                    If it's not there then your build of curl is somehow broken.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      RaJiska
                      wrote on last edited by RaJiska
                      #11

                      Ah, no problem, a bit of my fault too as I switched between then both at the begining as MinGW had troubles running my code I made with VS.

                      Concerning the dumpbin, it effectively doesn't seem to be there, here is its content (which is pretty short):


                      Microsoft (R) COFF/PE Dumper Version 12.00.31101.0
                      Copyright (C) Microsoft Corporation. All rights reserved.

                      Dump of file libcurl.lib

                      File Type: LIBRARY

                      Summary

                            C3 .debug$S
                            14 .idata$2
                            14 .idata$3
                             4 .idata$4
                             4 .idata$5
                             C .idata$6
                      

                      Now, here is how I built it at first:

                      1. Downloaded cURL 7.43.0 package
                      2. Opened prompt and inputed ' "<PathtoVS>/bin/vcvars32.bat" '
                      3. Inputed 'cd "<PathToCurlUpFolder>/curl-7.43.0/winbuild" '
                      4. Inputed 'nmake /f Makefile.vc mode=dll
                      5. Waited for it to finish, then went in 'libcurl-vc-x86-release-dll-ipv6-sspi-winssl'
                      6. Copied the content of include/curl in my project directory (which is correctly linked)
                      7. Did same as above with lib/libcurl.lib
                      8. Left untouched lib/libcurl.exp , bin/curl.exe , libcurl.dll

                      Is there something wrong I have been doing ?
                      Thanks.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        RaJiska
                        wrote on last edited by RaJiska
                        #12

                        Hello' Again,

                        I've decided to try it over MinGW compiler and a static build, apparently it got better but still have some errors.
                        Here is my .pro file:


                        QT += core gui widgets

                        TARGET = Launcher
                        TEMPLATE = app

                        SOURCES += main.cpp
                        mainwindow.cpp

                        HEADERS += mainwindow.h

                        FORMS += mainwindow.ui

                        DEFINES += CURL_STATICLIB
                        LIBS += -L"C:/Users/Banzai/Desktop/C++/QtPgrm/Mingw Real/includes/curl" -lcurl
                        LIBS += "C:/Users/Banzai/Desktop/C++/QtPgrm/Mingw Real/includes/curl/libcurl.a"
                        LIBS += "C:/Users/Banzai/Desktop/C++/QtPgrm/Mingw Real/includes/curl/libcurldll.a"
                        INCLUDEPATH += "C:/Users/Banzai/Desktop/C++/QtPgrm/Mingw Real/includes"

                        Also '#define CURL_STATICLIB' is declared in the header before the include of cURL.
                        Here is the error I got: error: undefined reference to `curl_easy_init'.
                        Not too sure what it could be. (I am using the 64 bits version while the compiler is 32 bits).

                        When I've been using the 32 bits version, here is what I got:


                        undefined reference to {WSAStartup@8,WSACleanup@0}
                        <path>/curl/libcurl.a(easy.o): bad reloc address 0x0 in section `.data'.

                        Apparently I've ready somewhere that I had to include something with -lwsock32, which I did this way:

                        LIBS += -lwsock32

                        Unfortunately it did not seem to change anything.
                        Thank you for your help.

                        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