[英]Can't compile libcurl with Codeblocks IDE in Ubuntu
我正在尝试在Ubuntu上的Codeblocks 16.01中编译此代码,但它会返回错误消息,其中包含对'curl_easy_init'的未定义引用 。
但是当我在终端gcc -L/usr/lib/x86_64-linux-gnu main.c -o curl -lcurl
不会返回任何错误。
我怎样才能解决这个问题?
#include <stdio.h>
#include <curl/curl.h>
void fileUpload()
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL,"http://test1:test1@www.idehn.tec.ac.cr/geoserver/rest/layers.xml");
/* 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));
FILE* file = fopen( "layers.txt", "w");
curl_easy_setopt( curl, CURLOPT_WRITEDATA, file) ;
/* 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);
fclose(file);
}
}
int main() {
//Call to the method that charge the url content to a file with all the layers.
fileUpload();
return 0;
}
我认为您忘记了告诉代码块与libcurl
链接:
curl
在此处在图像中查看它: https : //stackoverflow.com/a/5881751/1212012
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.