Shared Objects in a Non-Default Library Directory
When shared objects (
*.so) are located in a non-default library directory
lib_dir, during linking the option
-Llib_dir should be specified as usual. To be sure that the shared objects could be found during the linking stage at run time, one of the following should be done:
- Add lib_dir to the colon separated environment variable LD_LIBRARY_PATH to find them during execution.
- Add lib_dir to the colon separated environment variable LD_RUN_PATH to find them during linking.
- Use the -Wl,-rpath,lib_dir gcc option. The -Wl option takes care that the remaining comma separated words are passed as space separated wordt to the ld linker.
- Add lib_dir to the line separated library directories in /etc/ld.so.conf.
Adding
lib_dir to
LD_LIBRARY_PATH or to
/etc/ld.so.conf has the disadvantage that the names of the functions, used in these libraries, should not conflict with the names of other, standard functions.
Adding
lib_dir to
LD_RUN_PATH or with the
Wl,-rpath, option has the disadvantage that
lib_dir is not visible anymore after the compilation linking stage and therefore clould be easily forgotton. However, it has the advantage to be able to load specifiec shared objects only for specific executables.
Categories
CategorySysAdmin
CategoryProcedures
There are no comments on this page. [Add comment]