我制定计划,从QT的一个地点下载一个档案,但由于QT图书馆没有工作,我决定使用CURL。 根据有关网站文件部分的实例之一,我提出了以下守则:
下载者。
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
// Curl includes
#include "curl/curl.h"
#include "curl/types.h"
#include "curl/easy.h"
#include <QString>
#include <QObject>
class Downloader : QObject
{
Q_OBJECT
public:
Downloader();
void DownloadFile(QString url, QString directory);
signals:
void DownloadProgress(int downloaded, int total, QString message);
void DownloadComplete();
private:
void downProg(double t, double d, double ultotal, double ulnow);
void read(void *ptr, size_t size, size_t nmemb, FILE *stream);
void write(void *ptr, size_t size, size_t nmemb, FILE *stream);
};
#endif // DOWNLOADER_H
下载者。
#include "下载者。"
// Curl includes
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
Downloader::Downloader()
{
}
void Downloader::DownloadFile(QString url, QString directory) {
CURL *curl;
CURLcode res;
FILE *outFile;
//gchar *url = ptr;
QString outFileName = directory + "/tempDL/minecraft.jar";
curl = curl_easy_init();
if (curl) {
outFile = fopen(outFileName.toLocal8Bit().data(), "w");
char *urlC = url.toLocal8Bit().data();
curl_easy_setopt(curl, CURLOPT_URL, urlC);
}
}
void Downloader::downProg(double t, double d, double ultotal, double ulnow) {
}
void Downloader::read(void *ptr, size_t size, size_t nmemb, FILE *stream) {
}
void Downloader::write(void *ptr, size_t size, size_t nmemb, FILE *stream) {
}
甚至在建筑前,QT 造物人告诉我,当我上下线时:curl_easy_setopt(curl, CURLOPT_URL, urlC);
。 www.un.org/Depts/DGACM/index_french.htm
然后,在汇编该方案时,我收到<代码>。 Id 退回1份出境状况
在 little了一点之后,我怀疑这可能是某种定义性发言,但我无法在将他们从我的班子中除去后找到解决办法。
And this is my last resort for a file downloader, so I really need to make this work.
<><>Edit>:
在审查了汇编材料后,我发现如下。 我认为这可能有助于:
WARNING: Failure to find: Fetcher/http_fetcher.h
WARNING: Failure to find: Fetcher/http_error_codes.h
WARNING: Failure to find: Fetcher/http_fetcher.h
WARNING: Failure to find: Fetcher/http_error_codes.h
而且,在评论了有问题的法典范围后,发现2号错误似乎是由于这一法典线造成的:
curl = curl_easy_init();
<>Update:
After fooling around with this for days, it has done nothing but frustrate me. I ve decided to just try and get the default QT functions to work again instead of fooling with getting this to work. Thanks for your help.