Hi.
I read a hundred sites.
I try to run libraries third day.
But I can’t run my code.
I work on Windows 7 64bit
Tutorial [howtofix.pro]
Qt 5.3.1 for Windows 32-bit (MinGW 4.8.2, OpenGL) [download.qt-project.org]
Win – MinGW64 7.34.0 devel SSL SSH Günter Knauf [curl.haxx.se]
.pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
SOURCES += main.cpp
INCLUDEPATH += C:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\include\curl
LIBS += -LC:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\lib64 -lcurl
#LIBS += -LC:\Qt\Qt5.3.1\5.3\curl-7.34.0-devel-mingw64\lib64\libcurldll.a -this also didn't work
.cpp file:
#define CURL_STATICLIB
#include <stdio.h>
#include <curl.h>
#include <easy.h>
#include <string>
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
int main(void) {
CURL *curl;
FILE *fp;
CURLcode res;
char *url = "http://localhost/aaa.txt";
char outfilename[FILENAME_MAX] = "C:\\bbb.txt";
curl = curl_easy_init();
if (curl) {
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
return 0;
}
Always
“error: undefined reference to `curl_easy_init’”
“error: undefined reference to `curl_easy_setopt’”
“error: undefined reference to `curl_easy_perform’”
I add and link libraries.
I add “#define CURL_STATICLIB”
I copy libcurl dll files to Qt project Release/Debug
but it didn’t work.
Please help.
↧