On Linux, the ld.so(8)
man page discusses the search order for dynamic libraries. It says that DT_RPATH
is deprecated, and also mentions DT_RUNPATH
. There is no mention of the -rpath
linker option.
The ld(1)
man page mentions the -rpath
and -rpath-link
options, but never mentions DT_RPATH
or DT_RUNPATH
except in a describing the library search order, which of course does not match the information given in ld.so(8)
.
Finally there is an LD_RUN_PATH
environment variable. ld(1)
says it used if the -rpath
and -rpath-link
options are not set, but ld.so(8)
does not mention it.
My intuition is that -rpath
actually sets DT_RPATH
, and -rpath-link
sets DT_RUNPATH
, but I cannot find this confirmed anywhere. I have always used -rpath
; if it is the same as DT_RPATH
than I should not use it, but the how-to articles I've found on dynamic linking say to use it, so I'm not sure it's the same.
Could someone clarify how DT_RPATH
and DT_RUNPATH
are set, and whether they are the same as -rpath
and -rpath-link
?