Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use libCURL on Qt Creator with MSVC2012 as Compiler

Tags:

c++

curl

qt

libcurl

Curently I have installed on my system qt-windows-opensource-5.1.1-msvc2012-x86_64-offline

All works fine but I cant really succed to use libCurl on my Qt project.

I have downloaded this version of libcurl: http://curl.haxx.se/download/libcurl-7.19.3-win32-ssl-msvc.zip

MSVC metalink   7.19.3  devel   SSL         Frederic Elbin  4.04 MB

I have moved include folder from archive to VC include folder and I’ve included in program with #include and works good.

Now on the lib folder are another two folders with names: Debug and Release and both have some files inside.

On my .pro file I have added:

win32: LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/ -llibcurl_imp

INCLUDEPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc
DEPENDPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/release/ -lcurllib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/debug/ -lcurllib

INCLUDEPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/Debug
DEPENDPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/Debug

And now when I try to run a simple program I got:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "private: void __cdecl MainWindow::on_pushButton_clicked(void)" (?on_pushButton_clicked@MainWindow@@AEAAXXZ)

On downloaded archive are more other files too: http://img13.imageshack.us/img13/1416/reh8.png

Probably I’m now including libs fine (internal/external or dynamic/static) and I don’t know which one to include and how. And there are some .dll files too that I don’t know what to do with.

Have someone succesfully used libcurl on Qt projects? I’m beginer on Qt and it’s hard for me…

Thanks.

like image 437
caffeine Avatar asked Sep 23 '13 15:09

caffeine


2 Answers

Well I could tell how am I using libCurl in QT. If somone came across this question again. But I use mingw version, so it might be different.

In .pro file:

INCLUDEPATH += C:\Users\pagep\QT\curl-7.31.0-devel-mingw32\include
LIBS += C:\Users\pagep\QT\curl-7.31.0-devel-mingw32\lib\libcurldll.a

And in "debug" folder (folder where the program is executed) I added .dll files from folder curl-7.31.0-devel-mingw32\bin

libcurl.dll
libeay32.dll
libidn-11.dll
librtmp.dll
libssh2.dll
ssleay32.dll
zlib1.dll

Well it's probably not the best solution but it works for me. :)

like image 83
pagep Avatar answered Sep 27 '22 23:09

pagep


This may not be an answer to your question, but I would recommend using QNetworkAccessManager class instead of libcurl. You can do almost anything with this class which you can do using libcurl. Your code will be simpler and more cleaner. Some famous full featured Qt based download managers use this class.

like image 25
adnan kamili Avatar answered Sep 27 '22 22:09

adnan kamili