Results 1 to 11 of 11

Thread: Curl in QT Creator

  1. #1
    Join Date
    Jul 2011
    Location
    Kraków / Poland
    Posts
    32
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Curl in QT Creator

    Hello!
    I wanted to use curl lib in my program but I have problem with this lib in qt creator.
    In .pro file i have something like that:
    Qt Code:
    1. INCLUDEPATH += "D:/Qt/curl-7.21.6-devel-mingw32/include"
    2. win32:LIBS += -L"D:/Qtcurl-7.21.7-ssl-sspi-zlib-static-bin-w32" -lcurl
    To copy to clipboard, switch view to plain text mode 
    And in header file I am including curl/curl.h. QT Creator see the functions for curl, but when I want to build, I get:
    Qt Code:
    1. release/downloader.o:downloader.cpp:(.text+0x1b1): undefined reference to `_imp__curl_easy_init'
    2. release/downloader.o:downloader.cpp:(.text+0x1cd): undefined reference to `_imp__curl_easy_setopt'
    3. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 
    I found couple informations how to install curl in windows and use in qt creator but i always get that error. I tried to link .dll files and .a files, effect is the same. Of course I have declared appropriate:
    Qt Code:
    1. CURL *curl;
    2. curl = curl_easy_init();
    3. etc
    To copy to clipboard, switch view to plain text mode 
    I tried even install curl by mingw32-make, but even if i had installed libssl and zlib, I get errors about missing zlib, ssl and something else.
    I want to use curl, becouse in qnetworkaccessmeneger when i post into a site, then i get a message then i'm not using a cookie, even I setup them.
    I would be grateful if you could help me.
    Sory for my bad English
    Janusz

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Curl in QT Creator

    Try to include cURL header with extern "C"

    Qt Code:
    1. extern "C" {
    2. #include <curl/curl.h>
    3. }
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jul 2011
    Location
    Kraków / Poland
    Posts
    32
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Curl in QT Creator

    This didn't help,
    Qt Code:
    1. mingw32-make[1]: Leaving directory `D:/Qt/qtcreator-2.2.1/untitled4-build-desktop'
    2. release/downloader.o:downloader.cpp:(.text+0x1b1): undefined reference to `_imp__curl_easy_init'
    3. release/downloader.o:downloader.cpp:(.text+0x1cd): undefined reference to `_imp__curl_easy_setopt'
    4. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Curl in QT Creator

    I don't know anything about Curl, but a quick Google search with the error message (you must have done that too...) gives the impression that you need to define CURL_STATICLIB in your project

    (probably in .pro: DEFINES += CURL_STATICLIB)

  5. #5
    Join Date
    Jul 2011
    Location
    Kraków / Poland
    Posts
    32
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Curl in QT Creator

    Like I said, I found some information about this and i tried already add defines curl_staticlib but it didn't help. I thought then someone have problem like me and know how to resolve, but if no one know what to do with that, I have to find other solution without curl.
    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Curl in QT Creator

    have you built curl with the same compiler you're using for build your application?

    Post your PRO file
    A camel can go 14 days without drink,
    I can't!!!

  7. #7
    Join Date
    Jul 2011
    Location
    Kraków / Poland
    Posts
    32
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Curl in QT Creator

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2011-07-16T13:56:53
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8. QT += network
    9.  
    10.  
    11. TARGET = untitled4
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. project.cpp
    17.  
    18. HEADERS += project.h
    19.  
    20. FORMS += project.ui
    21.  
    22. INCLUDEPATH += "D:/Qt/curl-7.21.6-devel-mingw32/include"
    23. win32:LIBS += -L"D:/Qtcurl-7.21.7-ssl-sspi-zlib-static-bin-w32" -lcurl
    24. DEFINES += CURL_STATICLIB
    To copy to clipboard, switch view to plain text mode 
    I didn't build, just download already builded from curl site for windows/mingw32. When I tried to build from source with ssl and zlib, then I get error, "can't find -lz -lssl" or something like that, even if i already installed this lib.

  8. #8
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Curl in QT Creator

    Try defining CURL_STATICLIB BEFORE INCLUDEPATH and LIBS
    A camel can go 14 days without drink,
    I can't!!!

  9. #9
    Join Date
    Jul 2011
    Location
    Kraków / Poland
    Posts
    32
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Curl in QT Creator

    I found the solution. I define CURL_STATICLIB in my header file, before included curl.h.
    Thanks

  10. #10
    Join Date
    Aug 2011
    Posts
    1
    Platforms
    Windows

    Default Re: Curl in QT Creator

    I'm having the same problem since you found the solution, please help me out.

    This is my code:

    Qt Code:
    1. #include <stdio.h>
    2. #include <curl/curl.h>
    3.  
    4. int main(void)
    5. {
    6. CURL *curl;
    7. CURLcode res;
    8.  
    9. curl = curl_easy_init();
    10. /*
    11.   if(curl) {
    12.   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
    13.   res = curl_easy_perform(curl);
    14.  
    15.  
    16.   curl_easy_cleanup(curl);
    17.   }
    18.   */
    19. return 0;
    20. }
    To copy to clipboard, switch view to plain text mode 

    it returns the same error you were having: undefined reference to `_imp__curl_easy_init'

    by the way, I didn't compile the library (if it is necessary) I just downloaded and moved the curl library (that contains the curl.h, curlbuild.h) what do I need to do to make it work ? do I need to compile if yes, where do I do that, Its been days I've been looking for, But I don't understand what to do. I see something to use the mingw32-make mingw32 in the curl library but I don't get it fully. =/ please help me out, and also that CURL_STATICLIB what do I define in it? is it something in the code like this: #define CURL_STATICLIB

    By the way I'm using CodeBlocks that comes with the Mingw. I would be very glad if you could help me, step-to-step.

  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Curl in QT Creator

    I'm having the same problem since you found the solution, please help me out.
    ...
    By the way I'm using CodeBlocks that comes with the Mingw. I would be very glad if you could help me, step-to-step.
    So, you have a libCurl example program that uses the non-Qt Curl library. You are writing it using the non-Qt Code Blocks IDE and MingW. Why ask the question in a Qt forum?

    If you downloaded the libCurl source then you will need to build it. The instructions are in the source. Have you built it?

    If you have built it or downloaded a built version then either the compiler is not finding the built library, or you need to follow the preceding post, which tells you tell you exactly how to address this problem.
    that CURL_STATICLIB what do I define in it? is it something in the code like this: #define CURL_STATICLIB
    Did you try it before you posted?

Similar Threads

  1. Using QCA with QT Creator
    By mrstif in forum Newbie
    Replies: 4
    Last Post: 18th October 2010, 16:31
  2. cURL With Qt Creator [Windows and Linux]
    By Chiggins in forum Qt Tools
    Replies: 1
    Last Post: 24th June 2010, 08:29
  3. QT creator
    By tertius in forum Newbie
    Replies: 7
    Last Post: 21st June 2010, 10:41
  4. How to add MS SDK to QT Creator?
    By askrina in forum Newbie
    Replies: 3
    Last Post: 5th May 2010, 06:16
  5. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.