RPATH
RPATH is a runtime library search path embedded in an executable or shared library on many Unix-like systems. It tells the dynamic linker where to look for required shared libraries when the program starts. The path information is added at link time via the linker option -rpath (for example, -Wl,-rpath,/opt/mylib/lib) and is stored in the executable’s dynamic section as DT_RPATH or DT_RUNPATH.
In ELF binaries, DT_RUNPATH is the modern field, while DT_RPATH is the older one. When both may
RPATH is often considered less flexible than RUNPATH for relocatable installations. RUNPATH is generally favored because
A common technique to improve relocatability is to use relative paths, such as $ORIGIN, which expands to
Security and portability considerations apply: embedding absolute paths can hinder relocation and may complicate packaging or