When linking libraries, -rpath is used to pass the address of dynamic libraries to ld. My question is if I set the address in LD_LIBRARY_PATH, do I still need -rpath flag in my linking process?
Generally, you don't need it and in fact it's preferable to not have the library search path encoded in the executable (the -rpath
option encodes the path in the binary, either as DT_RPATH
or DR_RUNPATH
)
PS. My own general approach is to link executables with the --rpath
option, while they are in build tree and depend on other libraries in the build tree, to facilitate debugging, but upon installation (make install
, building packages) to re-link without --rpath
option and leave the task of finding the shared libraries to the appropriate dynamic linker configuration (e.g. ld.so.conf
) of the target platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With