基本上,我只是想使用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
答案 0 :(得分:9)
您需要链接到cURL库。
如果您正在使用gcc,请尝试使用
进行编译gcc -lcurl file.c
指定您需要链接libcURL。