加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 对libcurl函数的未定义引用

发布时间:2020-12-16 07:22:03 所属栏目:百科 来源:网络整理
导读:我无法编译,我在Odroid-XU4板上使用Ubuntu.我该如何解决这个问题?谢谢你的帮助. odroid@odroid:~/Desktop/curl_test.2$g++ -o postit2 postit2.c -lcurl/tmp/cc4MoKQE.o: In function `main':postit2.c:(.text+0x2c): undefined reference to `curl_mime_in
我无法编译,我在Odroid-XU4板上使用Ubuntu.我该如何解决这个问题?谢谢你的帮助.

odroid@odroid:~/Desktop/curl_test.2$g++ -o postit2 postit2.c -lcurl
/tmp/cc4MoKQE.o: In function `main':
postit2.c:(.text+0x2c): undefined reference to `curl_mime_init'
postit2.c:(.text+0x36): undefined reference to `curl_mime_addpart'
postit2.c:(.text+0x48): undefined reference to `curl_mime_name'
postit2.c:(.text+0x56): undefined reference to `curl_mime_filedata'
postit2.c:(.text+0xfa): undefined reference to `curl_mime_free'
collect2: error: ld returned 1 exit status
odroid@odroid:~/Desktop/curl_test.2$curl --version
curl 7.56.0 (armv7l-unknown-linux-gnueabihf) libcurl/7.47.0 
OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Release-Date: 2017-10-04
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps 
pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM 
NTLM_WB SSL libz TLS-SRP UnixSockets

解决方法

>从源安装最新版本的curl.无需删除现有卷曲.默认配置将安装在/usr/local下,但如果需要,可以在主目录下安装,这不需要root权限.配置选项是–prefix =`. >默认情况下,编译器和链接器都会在/usr/local中查找.如果你安装到不同的地方,你必须告诉tols在哪里.编译器选项是-I< directory-to-install> / include,链接器选项是-L< directory-to-install> / lib. >如果使用动态链接,则必须指定库在运行时的位置.运行时加载程序通常不会在/usr/local下查找,因此即使安装在那里也必须指定它.相关的gcc选项是-Wl,-rpath =< directory-where-libcurl.so-lives-at-run-time>.除非您正在为另一台计算机进行编译,否则这与安装libcurl.so的目录相同,因此您可能最终使用-L和-Wl,-rpath选项指定同一目录两次.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读