$linuxjunkies
>

rpath

also: run-time search path, RPATH

rpath (run-time search path) is a compiler and linker feature that embeds a list of directories into an executable, telling the dynamic linker where to search for shared libraries at runtime without relying on LD_LIBRARY_PATH.

rpath allows you to hardcode library search paths into a binary during compilation. When the executable runs, the dynamic linker (ld.so) checks these embedded directories first, before searching standard system paths.

You set rpath during linking with the -Wl,-rpath,/path/to/libs compiler flag. For example: gcc myapp.c -o myapp -Wl,-rpath,/opt/mylibs:/usr/local/lib embeds both paths into the binary.

This is useful for distributing self-contained applications with private library versions, avoiding conflicts with system libraries. However, it can reduce flexibility—if you want to upgrade a library, you must relink the binary. You can inspect rpath with readelf -d binary | grep RPATH or ldd binary.

Related terms