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?