Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In a Linux executable I am building with gcc I have linker options setting the rpath with:
'-Wl,-rpath=/some/path'
Yet if LD_LIBRARY_PATH is set to some path which contains the same version number of a shared library which my Linux executable needs at run-time the loader uses that instance of the shared library rather than the one in the directory I am setting with the -rpath linker option above. Why is that ? Does LD_LIBRARY_PATH really override the -rpath path I am setting in the executable itself ? That seems as if it must be a wrong design. How then can I ensure that the executable uses the shared library path which I set in the executable over anything that can be set by an environment variable.
BTW I can of course test that the above is actually happening with the ldd command.
For each object, DSO as well as executable, the author can define a
“run path”. The dynamic linker will use the value of the path string
when searching for dependencies of the object the run path is defined
in. Run paths comes is two variants, of which one is deprecated. The
runpaths are accessible through entries in the dynamic section as
field with the tags DT RPATH and DT RUNPATH . The dif- ference between
the two value is when during the search for dependencies they are
used. The DT RPATH value is used first, before any other path,
specifically before the path defined in the LD LIBRARY PATH
environment vari- able. This is problematic since it does not allow
the user to overwrite the value. Therefore DT RPATH is depre-
cated. The introduction of the new variant, DT RUNPATH , corrects this
oversight by requiring the value is used after the path in LD LIBRARY
PATH .
I can see from the 'readelf' command that it is setting the RUNPATH rather than the RPATH to what I specify as the '-rpath' option to the linker, and that is why the LD_LIBRARY_PATH is being searched first.
But why would the linker set the RUNPATH rather than the RPATH when I specify '-rpath' in my linker option ? I clearly want the RPATH set since I do not want the end-user to have the ability to override the order of the search path for shared libraries for the executable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.