- 论坛徽章:
- 0
|
回复 2# janetliu9
即使按你的说法做了,上层应用程序不指定libtest01,也是不行的诶。
[root@localhost test]# gcc -fPIC -shared -o libtest02.so test02.c -L./ -I./ -ltest01
[root@localhost test]# gcc -o test main.c -L. -I. -ltest02
/usr/bin/ld: warning: libtest01.so, needed by ./libtest02.so, not found (try using -rpath or -rpath-link)
./libtest02.so: undefined reference to `funtion1'
collect2: ld returned 1 exit status
[root@localhost test]# gcc -o test main.c -L. -I. -ltest02 -ltest01
[root@localhost test]#
[root@localhost test]# ldd test
linux-gate.so.1 => (0x00eff000)
★ libtest02.so => not found
★ libtest01.so => not found
libc.so.6 => /lib/libc.so.6 (0x00b91000)
/lib/ld-linux.so.2 (0x00b6b000)
[root@localhost test]# ldd libtest02.so
linux-gate.so.1 => (0x00fa5000)
★ libtest01.so => not found
libc.so.6 => /lib/libc.so.6 (0x0087f000)
/lib/ld-linux.so.2 (0x00b6b000)
编译libtest02.so的时候,依赖库确实不对,可是还是无法解决问题诶。o(╯□╰)o
[root@localhost test]# gcc -fPIC -shared -o libtest02.so test02.c -L./ -I./
[root@localhost test]# ldd libtest02.so
linux-gate.so.1 => (0x00afc000)
libc.so.6 => /lib/libc.so.6 (0x00301000)
/lib/ld-linux.so.2 (0x00b6b000)
★ 应该依赖libtest01.so的,但是没有加入进来 |
|