簡體   English   中英

對 libcurl 函數的未定義引用

[英]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 
  1. 從源安裝最新版本的 curl。 無需刪除現有的卷曲。 默認配置會將安裝放在 /usr/local 下,但如果需要,您可以安裝在您的主目錄下,這不需要 root 權限。 configure選項是--prefix=`。
  2. 默認情況下,編譯器和鏈接器都會在 /usr/local 中查找。 如果你安裝到不同的地方,你必須告訴工具在哪里。 編譯器選項是-I<directory-to-install>/include ,鏈接器選項是-L<directory-to-install>/lib
  3. 如果使用動態鏈接,則必須指定庫在運行時的位置。 運行時加載器通常不會在 /usr/local 下查找,因此即使安裝在那里也必須指定它。 相關的 gcc 選項是-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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM