I'm having trouble confirming my understanding of how rpath-link works when cross compiling with the specific tool chain I'm using (though I think this a general question that applies to cross compiling in general).
When I take a look at what flags are passed to the compiler and linker when building libraries and applications, I see the following passed to the linker:
-Wl,-rpath-link,/home/Dev/env/sys/crosscompiletoolchain/armle-v7/lib/
So this is a path being embedded into shared libraries being built for the target device on my development machine. This makes sense because I'd be doing all final linking on the development machine before deploying to device. When I finally deploy to the device though (ie. shared libs + application), won't those shared libs have a useless rpath-link?
The built libraries and applications seem to work fine on the target regardless, and if I'd have to guess I'd say its because the application has an environment provided by the device OS that has /lib/ as one of its default library search paths (rpath-link only specifies the first set of dirs to be searched). Is this correct?
The -rpath-link option may specify a sequence of directory names either by specifying a list of names separated by colons, or by appearing multiple times. The linker uses the following search paths to locate required shared libraries.
In computing, rpath designates the run-time search path hard-coded in an executable file or library. Dynamic linking loaders use the rpath to find required libraries. Specifically, it encodes a path to shared libraries into the header of an executable (or another shared library).
A cross compiler is useful to compile code for multiple platforms from one development host. Direct compilation on the target platform might be infeasible, for example on embedded systems with limited computing resources. Cross compilers are distinct from source-to-source compilers.
Check "Using LD, the GNU linker - Options - GNU Project Archives" (ftp.gnu.org/pub/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html):
The difference between -rpath and -rpath-link is that directories specified by -rpath options are included in the executable and used at runtime, whereas the -rpath-link option is only effective at link time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With