I am a newbie on Linux, so I have a lot of trouble with it.
I want to use curl in my Qt Project (C++). I created the project, then write in my main.cpp
#include <curl/curl.h>
int main( void ){
CURL *curl;
/* First step, init curl */
curl = curl_easy_init();
if (!curl) {
return -1;
}
return 0;
}
I tried compile that code, but have one error: undefined reference to 'curl_easy_init()' Than i realise, that QT Creator wants know path to library. I open test.pro file and append:
INCLUDEPATH += /usr/lib/x86_64-linux-gnu/
LIBS += /usr/lib/x86_64-linux-gnu/libcurl.a
LIBS += /usr/lib/x86_64-linux-gnu/libcurldll.a
And then error: libcurlldll.a no such file or dirrectory. Definetly a haven't this library, but i try install/reinstall all types of libcurl and it doesn't work.
Sites, where i tried to search information:
http://www.cplusplus.com/forum/general/89488/
http://curl.haxx.se/libcurl/using/apps.html
https://stackoverflow.com/
Please, redirect me to very simple guide "How use libcurl in QT Creator on Debian" or something like that. I need step-by-step guide. Or can you write it to me there, then everyone can use it?
Sorry for my english, i am just learning. Thanks!
This works for me just fine:
#include <curl/curl.h>
int main( void ){
CURL *curl;
/* First step, init curl */
curl = curl_easy_init();
if (!curl) {
return -1;
}
return 0;
}
TEMPLATE = app
TARGET = curl
QT -= core gui
LIBS += -lcurl
# CONFIG += link_pkgconfig
# PKGCONFIG += curl
SOURCES += main.cpp
As you can see in the comment, you could also use pkgconfig instead of the LIBS
variable which would probably be even neater.
Make sure you have all the corresponding packages installed that are necessary, for instance the development, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With