如何使编译程序时连接另外的库而不是系统标准的C库
msenb 2005-09-26 07:00:37 我重新编译了一个C库libc.so放在/root 目录下,
然后写了一个程序test.c 用来测试新库,想编译test.c的时候用的是新库libc.so而不是系统C库.
用命令 gcc test.c -L /root -lc -o test 会报错:
/usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/../../../crt1.o(.text+0x42): In function `_start':
: undefined reference to `__libc_csu_init'
/usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/../../../crt1.o(.text+0x52): In function `_start':
: undefined reference to `__libc_csu_fini'
collect2: ld returned 1 exit status
而用命令 gcc test.c -L /root -l libc.so -o test 则报 :
/usr/bin/ld: cannot find -llibc.so
collect2: ld returned 1 exit status
一直编译不过去,我看gcc手册里也就这几个参数是和库文件相关了