You would be interested in removing library paths if a given shared library has embedded paths via the rpath feature. Those are added at the time the library is created by the linker.
You can remove (or alter) those paths using chrpath
, e.g.,
chrpath -d mylibraryfile.so
Removing pathnames from the LD_LIBRARY_PATH
variable also is a possible area of interest; you can do that by string substitution and re-exporting the variable. However, the question does not seem to be concerned with that. There is no variable which acts to cancel out LD_LIBRARY_PATH
.
For seeing library dependencies, the mention of /etc/ld.so.conf.d/
makes it sound as if the platform is only Linux. You can use ldd
to list dependencies. Aside from OSX, all of the BSDs also support ldd
. Here is one of the scripts which I use for this purpose:
#!/bin/sh
# $Id: ldd-path,v 1.1 2007/07/09 19:30:28 tom Exp $
# Edit the output of ldd for the given parameters, yielding only the
# absolute pathnames.
ldd $* | sed \
-e 's/([^)]*)//g' \
-e 's/^.*=>//' \
-e 's/[ ][ ]*//g' \
-e '/^$/d'
But (addressing a comment), there is no portable mechanism for telling the loader to ignore an existing path. The GNU ld documentation gives a summary of what is sought, and the order in the description of the -rpath
option. These items conclude the list:
- The default directories, normally
/lib
and /usr/lib
.
- For a native linker on an ELF system, if the file
/etc/ld.so.conf
exists, the list of directories found in that file.
Further reading
Best Answer
You can do this with
ldd
command:Example: