所以我从 curl 网站下载了 zip 文件。我将包含所有头文件的目录复制到我的包含目录中。包括 curl.h 没有问题,但是,当我去实际调用一个函数时,突然我的 C++ 应用程序将不再编译。
这是我收到的错误:
[Linker error] undefined reference to
`curl_easy_init'
Run Code Online (Sandbox Code Playgroud)
这是代码:
#define CURL_STATICLIB
#include <curl/curl.h>
#include <string>
#include <iostream>
using namespace std;
int main() {
string url = "http://www.google.com";
cout << "Retrieving " << url << endl;
// Our curl objects
CURL *curl;
CURLcode result;
// Create our curl handle
curl = curl_easy_init();
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我注释掉 curl=curl_easy_init() 行,它工作正常。
根据文档,这应该可以工作,如下所示。
有任何想法吗?
您必须将您的程序与curl库链接
-L/path/of/curl/lib/libcurl.a (g++)
Run Code Online (Sandbox Code Playgroud)
或在您的解决方案中添加curl
Solution->properties->Link(ing) and add libcurl.lib
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16740 次 |
| 最近记录: |