我正在尝试使用静态标志(静态链接)构建一个C程序。当我尝试这样做时,链接器抛出一个错误“找不到用于-lc的库”。我使用的机器是HP-UX。我不知道它需要哪个库以及在哪里可以找到它,以便在使用-L选项构建程序时可以包含默认搜索位置。

avotclbh:/home/akhils/test_prog#
avotclbh:/home/akhils/test_prog#gcc -v
Using built-in specs.
Target: ia64-hp-hpux11.31
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
You have mail in /var/mail/root
avotclbh:/home/akhils/test_prog#


avotclbh:/home/akhils/test_prog#gcc -v -static test_debugging.c -o test_debugging.out -L/usr/lib/hpux64
Using built-in specs.
Target: ia64-hp-hpux11.31
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/cc1 -quiet -v test_debugging.c -quiet -dumpbase test_debugging.c -auxbase test_debugging -version -o /var/tmp//ccjCisnQ.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../ia64-hp-hpux11.31/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include
 /usr/include
End of search list.
GNU C version 4.2.3 (ia64-hp-hpux11.31)
        compiled by GNU C version 4.2.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 207e4f838aed34ece15d2a59ed6e0ca7
 /usr/local/bin/as -x -o /var/tmp//cceZpXhF.o /var/tmp//ccjCisnQ.s
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/collect2 -z +Accept TypeMismatch -u main -noshared -o test_debugging.out crt0.o /usr/lib/hpux32/unix98.o -L/usr/lib/hpux64 -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3 -L/usr/ccs/lib -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../.. /var/tmp//cceZpXhF.o -lgcc -lc -lgcc
**ld: Can't find library for -lc
Fatal error.
collect2: ld returned 1 exit status**
avotclbh:/home/akhils/test_prog#

另外,我已经在计算机上安装了以下依赖项
avotclbh:/home/akhils/test_prog#swlist -l product |grep -iE "gcc|zlib|libiconv|gettext"
  gcc                   4.2.3          gcc
  gettext               0.19.5.1       gettext
  libiconv              1.14           libiconv
  zlib                  1.2.8          zlib
avotclbh:/home/akhils/test_prog#

最佳答案

安装库包。

关于c - ld:找不到-lc的库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34178941/

10-11 15:15