基本上,我尝试简单地使用 libCURL 来下载网站,并且我一直在使用以下代码:
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
并收到此错误:
Undefined symbols:
"_curl_easy_perform", referenced from:
_main in ccGyMZQR.o
"_curl_easy_init", referenced from:
_main in ccGyMZQR.o
"_curl_easy_setopt", referenced from:
_main in ccGyMZQR.o
"_curl_easy_cleanup", referenced from:
_main in ccGyMZQR.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
您需要链接到 cURL 库。
如果您使用 gcc,请尝试使用以下命令进行编译
gcc -lcurl 文件.c
这指定您需要链接 libcURL。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)