Find out if library is in path

ldconfig can list all the libraries it has access to. These libraries are also stored in its cache.

/sbin/ldconfig -v -N will crawl all the usual library paths, list all the available libraries, without reconstructing the cache (which is not possible if you're a non-root user). It does NOT take into account libraries in LD_LIBRARY_PATH (contrarily to what this post said before edit) but you can pass additional libraries to the command line by using the line below:

/sbin/ldconfig -N -v $(sed 's/:/ /g' <<< $LD_LIBRARY_PATH)

You can compile a simple test program with gcc and link your library. Then you can check the used libraries with ldd. I use something like this:

echo "int main(){}" | gcc -x c++ -Wl,--no-as-needed -lmylib - && ldd a.out | grep mylib

-Wl,--no-as-needed prevents the linker from discarding the library, because no symbols from the library are used.


Globally substitute (space) for : with LD_LIBRARY_PATH

/sbin/ldconfig -N -v $(sed 's/:/ /g' <<< $LD_LIBRARY_PATH)