c – 无法使用curl – undefined引用在Linux中编译
发布时间:2020-12-16 07:31:47 所属栏目:百科 来源:网络整理
导读:我正在尝试使用curl lib在 Linux(ubuntu)中编译一个c示例但我得到’curl_easy_init’的未定义引用 编译命令: gcc -L/usr/local/lib -lcurl -I/usr/local/include -o request request.cpp 结果: /tmp/ccZwDiCf.o: In function 'main':brrequest.cpp:(.text+
我正在尝试使用curl lib在
Linux(ubuntu)中编译一个c示例但我得到’curl_easy_init’的未定义引用
编译命令: gcc -L/usr/local/lib -lcurl -I/usr/local/include -o request request.cpp 结果: /tmp/ccZwDiCf.o: In function 'main':<br> request.cpp:(.text+0xa): undefined reference to 'curl_easy_init'<br> request.cpp:(.text+0x31): undefined reference to 'curl_easy_setopt'<br> request.cpp:(.text+0x3d): undefined reference to 'curl_easy_perform'<br> request.cpp:(.text+0x54): undefined reference to 'curl_easy_strerror'<br> request.cpp:(.text+0x7b): undefined reference to 'curl_easy_cleanup'<br> collect2: ld returned 1 exit status 码: #include <curl/curl.h> #include <stdio.h> int main(int argc,char* argv[]){ CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl,CURLOPT_URL,"http://google.com"); res = curl_easy_perform(curl); if(res!=CURLE_OK) fprintf(stderr,"curl_easy_perform() failed: %sn",curl_easy_strerror(res)); curl_easy_cleanup(curl); } return 0; } 解决方法
回答只是为了结束这个问题.
对于resumate,您必须将-lcurl选项放在编译命令行的末尾. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |