Prismatic
Prismatic

Reputation: 3348

How is rpath-link used in cross compilation?

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?

Upvotes: 6

Views: 6633

Answers (1)

Zrin
Zrin

Reputation: 981

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.

Upvotes: 14

Related Questions