How to use/configure cURL on Qt Creator?
-
Hello!
By a few days I'm trying to use cURL on my Qt project. But I got many headaches and I decided to ask you.
When I'm trying to use cURL functions I got this error:
@mainwindow.obj : 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)
debug\Curl.exe : fatal error LNK1120: 1 unresolved externals@The main program looks like:
@#include "mainwindow.h"
#include "ui_mainwindow.h"#include <curl/curl.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_pushButton_clicked()
{
//shits here
CURL *curl;
curl = curl_easy_init();
}@I'm using Visual Studio 2012 Compiler
And the curl files from Microsoft Visual Studio 11.0\VC\include\curl :
!http://img856.imageshack.us/img856/359/1r58.png(curl)!I've read on other forums that I have to add library dependency, but I'm beginer with Qt and I don't know hot to do that.
thanks.
-
Hi and welcome to devnet,
If you are using QtCreator, right click on your project and select Add Library, then point it to your curl lib file.
You should be good to go then
-
I've donne that, but is a problem with libs and get this error:
@LINK : fatal error LNK1104: cannot open file 'libcurl_imp.lib'@
I've added libs as externals and set correct path to these but still get this error.
Why can't open libs?
Edit: Finally after spenting other some hours of searching this tutorial saves my life:
"http://www.cplusplus.com/forum/general/89488/":http://www.cplusplus.com/forum/general/89488/ -
Do you have the path properly quoted ?
I am also wondering what does these files do in Visual Studio's installation
-
That's generally a bad idea to move files around like that on windows.
-
However my problems is not solved. I want to explain again, maybe now I will get the solution.
Curenntly I have installed qt-windows-opensource-5.1.1-msvc2012-x86_64-offline
And I've downloaded this version of libcurl:
!http://img13.imageshack.us/img13/7157/yv4z.png(qt curl)!The curl folder is:
!http://img13.imageshack.us/img13/1416/reh8.png(123)!I have moved include include folder to VS include folder and I've included in program with *#include <curl/curl.h> * and works good.
Now on the lib folder are another two folders with names: Debug and Release
and both have these files inside:!http://img854.imageshack.us/img854/4610/7993.png(123)!
And now when I try to run a simple program i got:
!http://img585.imageshack.us/img585/7476/4qjw.png(qt)!
If you can't understand from images you can download archive with curl right here:
http://curl.haxx.se/download/libcurl-7.19.3-win32-ssl-msvc.zipI've tried to include libs on project but failed, everytime I got the same error. 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.