【发布时间】:2014-02-19 00:08:44
【问题描述】:
我是 C++ 新手,有兴趣编写一个简单的应用程序来从 Internet 下载 HTTP 文件并处理它的内容)。无论如何,我在网上找到了一个名为 libcurl 的库。我去了以下网站:
http://curl.haxx.se/download.html
- 我应该下载源存档还是二进制包(Win64 MinGW64)?使用源存档与二进制 pkg 有什么区别和优缺点?
- 由于我正在编写 C++ 应用程序,是否应该使用 curlcpp 绑定?如何将 curlcpp 绑定与此合并?
无论如何,我下载了 curl-7.34.0.zip(源存档),其中包含许多文件夹。我怀疑我需要包含的文件夹是:
- 包括
- 库
- 源代码
我使用了 CodeBlocks IDE。我“递归地添加”文件夹“include/curl”到我的项目中。它看起来像这样:
我的 main.cpp 包含以下代码(取自网站上的示例应用程序):
#include <iostream>
#include <stdio.h>
#include "curl/curl.h"
using namespace std;
int main()
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
我在尝试构建/编译时收到以下错误消息。
undefined reference to '_imp__curl_easy_init'
undefined reference to '_imp__curl_easy_setopt'
undefined reference to '_imp__curl_easy_perform'
undefined reference to '_imp__curl_easy_strerror'
undefined reference to '_imp__curl_easy_cleanup'
我不确定我遗漏了什么,或者我的文件夹目录是否被错误地使用。您有什么建议可以帮助我通过 Source Archive 或 Binary Package 构建它吗?谢谢。
【问题讨论】:
标签: c++ build compilation compiler-errors libcurl