Problem setting up Curl
-
I am trying to revive a project witten in an older version of Qt. It contains implementations based upon cUrl.
But I don't seem to get the cUrl stuff to work. It builds seemingly ok, but then keeps crashing (The program has unexpectedly finished.)Btw I am a newbie at this...
For demonstration purposes I have reduced my code to the absolute minimum.
Error message:
11:54:25: Starting D:\Workspaces\build-Curl-Desktop_Qt_5_12_11_MinGW_32_bit-Debug\debug\Curl.exe ... 11:54:25: The program has unexpectedly finished. 11:54:25: The process was ended forcefully. 11:54:25: D:\Workspaces\build-Curl-Desktop_Qt_5_12_11_MinGW_32_bit-Debug\debug\Curl.exe crashed.
My .pro file:
QT -= gui CONFIG += c++11 console CONFIG -= app_bundle # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target win32: LIBS += -L$$PWD/../libs/curl-7.64.0-win32-mingw/lib/ -lcurl INCLUDEPATH += $$PWD/../libs/curl-7.64.0-win32-mingw/include DEPENDPATH += $$PWD/../libs/curl-7.64.0-win32-mingw/include
The main.cpp
#include <QCoreApplication> #include <curl/curl.h> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); CURL *curl = curl_easy_init(); curl_easy_cleanup(curl); return a.exec(); }
-
Hi,
Did you check that the curl dll can be loaded at run time by your application ?
If not, either copy the dll in the build folder or add the path to the curl dll to the PATH environment variable in the Run part of the Project panel.
-
Everyday I get smarter and smarter... thanks, that did the trick! ;-)
Btw do you know of any good resources that would help a newbie like me to get these external libraries explained? And how to package them correctly?
Thank you very much,
Geert
-
The rules on Windows to avoid DLL hell are pretty simple:
- Deploy the dlls your application requires in the same folder as your executable (plugins like Qt's own can live in different folders though).
- Do NOT install any dll in system folders. This can have unexpected side effects and wreak havoc.
- Unless really required (most of the time it's not), do not modify the PATH environment variable.