Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between LD_LIBRARY_PATH and -rpath

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?

like image 982
Ju Liu Avatar asked Nov 29 '12 01:11

Ju Liu


1 Answers

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.

like image 77
chill Avatar answered Oct 18 '22 21:10

chill