- To: Zhengxiong Zhang <zzhan@xxxxxxxxx>
- Subject: Re: GCC 4.6.1: ld cannot find shared libraries when in sysroot
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Mon, 14 May 2012 15:08:04 -0700
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <4FAF4EC4.2080408@umich.edu> (Zhengxiong Zhang's message of "Sun, 13 May 2012 02:03:48 -0400")
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Zhengxiong Zhang <zzhan@xxxxxxxxx> writes:
> 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?
How did you build the GNU binutils? If you configure the linker with
the right --sysroot option at configure time, I think it will work.
However, this ought to work anyhow. I think the bug is that if you
don't use --sysroot when configuring the linker, the default library
path is empty. This should be set based on whether --sysroot is used at
runtime, not on whether it is used at configure time.
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]