[英]Compiling error in Gcc
我用C語言編寫了一個程序。
gcc -o pr prc.c
然后我得到了下面的東西
/usr/bin/ld:cannot find -lc
collect2: ld returned 1 exit status
鏈接程序( ld
)找不到標准C庫的庫文件libc.{a|so}
。 請參閱ld手冊頁 ,以在OPTIONS部分中提及此庫(以及ld
lc
命令行選項)。 報價:
ld -o <output> /lib/crt0.o hello.o -lc
This tells ld to produce a file called output as the result of linking
the file "/lib/crt0.o" with "hello.o" and the library "libc.a"
您應該檢查以確保系統中實際上缺少這些文件。 在我的Ubuntu 10.04 LTS系統上:
~ [88] locate libc.so
/lib/libc.so.6
/lib/tls/i686/cmov/libc.so.6
/usr/lib/libc.so
~ [89] locate libc.a
/usr/lib/libc.a
/usr/lib/xen/libc.a
根據缺少的發行版,如何安裝缺少的庫。 使用您的軟件包管理來搜索libc
。 否則,您可能需要考慮重新安裝gcc
-lc是C
運行時庫libc的縮寫。 無論您的* nix發行版是什么,都需要通過適當的安裝程序安裝glibc和glibc-common。
man ld
,這應該可以洞悉錯誤消息。 此類消息表明鏈接器正在尋找缺少的庫。 此處的庫名稱為libc(用lib替換l)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.