[英]Undefined references to libcurl functions
我無法編譯,我在 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
configure
選項是--prefix=`。-I<directory-to-install>/include
,鏈接器選項是-L<directory-to-install>/lib
。-Wl,-rpath=<directory-where-libcurl.so-lives-at-run-time>
。 除非您為不同的機器編譯,否則這是安裝 libcurl.so 的同一目錄,因此您最終可能會使用 -L 和 -Wl,-rpath 選項兩次指定相同的目錄。鏈接器在其配置的路徑中查找 libcurl 並首先找到舊版本。
編輯/etc/ld.so.conf
以使鏈接器在具有新 libculr 版本的目錄中查找。
或者重新安裝 libcurl:
sudo apt-get remove libcurl
wget http://curl.haxx.se/download/curl-7.56.0.tar.gz
./configure
make
make install
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.