How to use libCURL for Qt Creator with MSVC2012 as a compiler

In short, I installed qt-windows-opensource-5.1.1-msvc2012-x86_64-offline in my system

Everything works fine, but I really could not use libCurl in my Qt project.

I 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 moved the include folder from the archive to the VC include and Ive folder included in the program with #include and it works fine.

Now in the lib folder there are two more folders with names: Debug and Release, and both have several files inside.

In my .pro file, I 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) 

The downloaded archive also contains other files: http://img13.imageshack.us/img13/1416/reh8.png

Probably Im now includes the libs fine functions (internal / external or dynamic / static), and I don't know which one to include and how. And there are also some DLL files that I don’t know what to do with them.

Has anyone successfully used libcurl for Qt projects? Im a beginner on Qt and its hard for me ...

Thanks.

+6
source share
2 answers

Well, I can tell how I use libCurl in QT. If someone came across this issue again. But I use the mingw version, so it may be different.

In the .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 the "debug" folder (the folder in which the program is running) I added .dll files from the curl-7.31.0-devel-mingw32 \ bin folder

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

Well, this is probably not the best solution, but it works for me. :)

+2
source

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

+2
source

Source: https://habr.com/ru/post/954433/


All Articles