Is there a GNU Linux built-in for getting a list of the filenames of shared libraries? I have considered parsing the output of ldconfig -p
. However, I'm not sure about consistency in output from system to system.
I am already aware that I could use find
but given that the linker / loader has a cache of libraries and locations, it seems more efficient to use it in some way. Additionally, the paths that the linker / loader searches are the only ones I'm concerned with–i.e libraries that have been processed by ldconfig
.
Best Answer
If you want to catch them all, there is no other choice but to do full filesystem traversals.
ldconfig
knows only about the libraries in the standard paths and the extra paths it is configured to look in (usually defined in/etc/ld.so.conf*
). The usual suspect places where other libraries can be found are$HOME
and/opt
, though there is no limit, especially when people build applications themselves.If you don't trust the output of
ldconfig -p
, you can parse its cache directly. It's binary, but usingstrings
removes all the garbage (5 so /lib/ matches):On my system, they both give the same results, which I verified with this quicky:
Which checked if any library on the
ldconfig -p
list was not mentioned in the cache. Nothing was returned.