Hello, This bug report is 14 years old. I spent the past 3 years on and off tracking down this same issue. I even made my own example almost identical to the one already attached. You can find it here:
https://github.com/ali1234/autofools/ In my example the libs are called libfoo and libbar instead of liba and libb. Everything else is the same. > Explanation: > when gnu-ld links exec native, it will search the rpath in the library to > resolve symbols recursively. > when gnu-ld links exec for cross compilation, it will not use rpath > (probably because it can't know the runtime linker that will be used). This is not quite true - and it might be because binutils/ld behaviour changed at some point in the past 15 years. ld always searches rpath, but it always prefixes it with the sysroot. When you do a native compile, the sysroot is "/" which results in no change to the rpath. But when you cross compile, typically you set the sysroot to wherever the system libraries you want to build against are located. Since most cross compilers are not configured for multiarch, this is almost never "/". In my example the compiler (which is from linaro) is configured to look for the sysroot in a location relative to where it is installed. It takes the rpath from libbar and prefixes it with the sysroot, resulting in it looking in completely the wrong place: 28962 openat(AT_FDCWD, "/home/al/autofools/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/home/al/autofools/autofools-cross/foo/.libs/libfoo.so.0", O_RDONLY) = -1 ENOENT (No such file or directory) Here, /home/al/autofools/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc is the sysroot, and /home/al/autofools/autofools-cross/foo/.libs/libfoo.so.0 is the actual location of the required library. Setting -Wl,--rpath-link=/home/al/autofools/autofools-cross/foo/.libs/ allows ld to find the library and my understanding is that this does not introduce over-linking, but I am not really sure about that. -- Alistair Buxton a.j.bux...@gmail.com