V
V
Vladimir2016-05-24 13:34:26
Qt
Vladimir, 2016-05-24 13:34:26

How to connect libcurl to Qt?

Good afternoon!
It was necessary to write an HTTP client, but I have no experience with networks (only a few lectures at the university).
On the Internet, I found a suitable option for myself, using the libcurl library.
Having installed the library, successfully compiled it under Linux, launched it - everything works like clockwork. But for the convenience of work, I would like to continue writing the rest of the code in Qt.
I went to the official website https://curl.haxx.se/download.html. Next, I downloaded the version I needed
1d1c11aa5dbb4955b59f35d67f104333.png.
In my project in .pro I registered the paths:

  • INCLUDEPATH += C:\Qt\curl-7.49.0-win32-mingw\include
  • libs += -LC:\Qt\curl-7.49.0-win32-mingw\lib\libcurl.a
  • DEFINES += CURL_STATICLIB

I also copied the dll from the bin folder to the debug/release project and windows/system32.
I wrote #include in the main file.
But when compiling, it gives errors like "undefined reference to `curl_easy_init'", etc. for each function.
I looked for answers, but everywhere the error is solved by adding paths to .pro howtofix.pro/tutorial-libcurl-on-qt-creator-with-m... Or the problem is a mismatch between compiler versions.
On Qt ( Qt Creator 3.5.1, based on Qt 5.5.1 (MSVC 2013, 32 bit) ) I have MinGW 32 bit. Tried downloading different versions of libcurl: Win32 - Generic, Win64 - Generic, Win64 - MinGW64.
Where is the mistake?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mercury13, 2016-05-24
@zveropasen

It is necessary to connect libcurldll.a in this form.
Here is a piece taken from a real project.

win32|win64: LIBS += -lws2_32 -lshlwapi -lodbc32 -lpsapi -lcomdlg32 \
                     -L$$PWD/../../Common/cURL/lib/ -lcurldll -lole32 \
                     -loleaut32

Also, if you're missing OpenSSL - find libeay32.dll and ssleay32.dll better compiled with an older version of MSVC and don't require new runtimes that aren't available everywhere. Oh yes, there are versions of libcurl that are compiled without SSL - they don't need that, of course.
Wait, now I'll see what happens if I compile the cURL library into the program statically, without the DLL.
UPD. Tried. It almost works, but I need to figure out how to connect winsock and OpenSSL - before, the one who compiles the DLL dealt with them, but now it will be my concern.

V
Vladimir Martyanov, 2016-05-24
@vilgeforce

Did you register the LIB file on Windows as a library?

A
Alexey, 2016-05-24
@MAKAPOH

If you don't have a requirement to work specifically with the MSVC compiler, then you can take Qt along with curl from MSYS2 . I often use this assembly, everything is compatible with each other (it is assembled by one compiler). I didn’t try curl, but about a dozen other libraries work in the project without problems.

J
Jacob E, 2016-05-24
@Zifix

Why not network with Qt?

The Chukchi bought a Kamaz for himself, came home, gathered his relatives in his tent, sits, says:
- A good Kamaz car. It's warm in the cabin, the headlights illuminate the taiga ... one thing is bad - the dogs get tired quickly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question