How to set RunPath of a binary?

2019-02-18 16:25发布

问题:

There are countless threads describing what is RPATH, RUNPATH and LD_LIBRARY_PATH and how they interact in order to resolve libraries' location.

To set RPATH use gcc options:

-Wl,-rpath,/path/to/dir

To set LD_LIBRARY_PATH use:

export LD_LIBRARY_PATH= <path of lib>

What I cannot find is how to set RUNPATH?

回答1:

Seems runpath is set to the -Wl value if you pass --enable-new-dtags

http://blog.tremily.us/posts/rpath/

This links seems to suggest the difference in use for rpath and runpath seems to be their order in the search list:

http://en.wikipedia.org/wiki/Rpath



标签: linux gcc linker