This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Why cannot insert Dynamic Linker path?
- From: Samson Luk <samsonluk at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 14 Oct 2010 10:57:18 +0800
- Subject: Why cannot insert Dynamic Linker path?
I've alternate sysroot installed in my system and I alway use the
following gcc command to insert alternate dynamic linker path to new
compiled binary:
$ gcc -O2 -Wl,-rpath=/usr/lib/cs2010q1/lib:/usr/lib/cs2010q1/usr/lib
-Wl,--dynamic-linker=/usr/lib/cs2010q1/lib/ld-linux.so.3 main.c -o
main
$ ldd main
libgcc_s.so.1 => /usr/lib/cs2010q1/lib/libgcc_s.so.1 (0x40028000)
libc.so.6 => /usr/lib/cs2010q1/lib/libc.so.6 (0x4003b000)
/usr/lib/cs2010q1/lib/ld-linux.so.3 (0x40000000)
However, I found '-Wl,--dynamic-linker' seems no effect for create
dynamic link shared library, it doesn't insert the dynamic linker path
to the final .so:
$ gcc -shared -O2
-Wl,-rpath=/usr/lib/cs2010q1/lib:/usr/lib/cs2010q1/usr/lib
-Wl,--dynamic-linker=/usr/lib/cs2010q1/lib/ld-linux.so.3
-L/usr/lib/cs2010q1/lib -L/usr/lib/cs2010q1/usr/lib -L/opt/lib
-L/opt/lib/gcc/arm-none-linux-gnueabi/4.4.3 -L/usr/local/lib
-L/usr/local/BerkeleyDB.4.2/lib -fno-stack-protector JP.o cp_00_t.o
eu_01_t.o ji_02_t.o ji_03_t.o ji_04_t.o ma_05_t.o sh_06_t.o -o JP.so
$ ldd JP.so
libgcc_s.so.1 => /usr/lib/cs2010q1/lib/libgcc_s.so.1 (0x40132000)
libc.so.6 => /usr/lib/cs2010q1/lib/libc.so.6 (0x40145000)
/lib/ld-linux.so.3 (0x2a000000)
as you can see the JP.so only have the /lib/ld-linux.so.3 instead of
the /usr/lib/cs2010q1/lib/ld-linux.so.3 as the dynamic linker path.
Appreciate for your suggestion on how to fix this problem. I am using
gcc 4.4.3 in arm-linux 2.6.16
Regards,
Samson