- To: gcc-help@xxxxxxxxxxx
- Subject: GCC 4.6.1: ld cannot find shared libraries when in sysroot
- From: Zhengxiong Zhang <zzhan@xxxxxxxxx>
- Date: Sun, 13 May 2012 02:03:48 -0400
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
I am trying to build some software in a 32-bit sysroot that shares the
same directory organization as my 64-bit system. In my project, I build
a dynamic library that links to other dynamic libraries as follows:
g++ -o libmylibrary.so -Wl,-Bdynamic -shared --sysroot=/sysroot {bunch
of objects} -m32 -lsomeotherlibrary
I then attempt to build an application that links to my static library
as follows:
g++ -o myprog --sysroot=/sysroot {bunch of objects} -m32 -lmylibrary
However, this time I get a bunch of errors like this:
/usr/bin/ld: warning: libsomeotherlibrary.so needed by libmylibrary.so,
not found (try using -rpath or -rpath-link)
[bunch of errors about undefined references to someotherlibrary]
Adding -Wl,-rpath-link=/sysroot/usr/lib causes myprog to successfully
link. This behavior confuses me because it seems to me that ld should be
able to find libsomeotherlibrary.so in /sysroot/usr/lib/ just like it
did when I built libmylibrary.so. Can someone explain this to me and
describe how I can change my build process to avoid this?
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]