Effect of using the -rpath linkler option

Edward Diener eldlistmailingz@tropicsoft.com
Wed Oct 3 22:16:00 GMT 2018


I am using gcc 7.2.0-19 on a Debian OS running on an arm-64 SOM. For an 
executable I am building, call it XXX, using a shared library, which I 
also build, call it YYY, I am specifying a linker option when linking 
the object files to final executable form of:

'-Wl,-rpath=/some/path'

so that XXX finds YYY at both linktime and runtime at /some/path. 
However after the executable is built the 'readelf' utility shows me 
that the RUNPATH is set by my -rpath setting rather than the RPATH. What 
this means is that an end-user can set an LD_LIBRARY_PATH which is 
searched before the -rpath I am setting in my executable for library 
YYY. This is not what I want.

Why does the -rpath set the RUNPATH rather than the RPATH ?

How can I make sure that the executable finds YYY in the -rpath I want 
both at link time and run time, rather than in some possible place in 
the LD_LIBRARY_PATH ?



More information about the Gcc-help mailing list