Unix & Linux Asked by Wang on October 31, 2021
Some of distro is /lib64
some of them is /lib/x86_64-linux-gnu
, there maybe other format. Is there a uniform way to determine this in bash?
First you should figure out the goal to specify the path. It can be one of:
For (3), the only real source is distro policy description that is a human readable document. You can't determine this from /etc/ld.so.conf
, ldconfig
cache, etc., because you can't find out what location is preferred and what one is legacy; some hint on this can be got by counting libraries but this is definitely not work for shell script.
For (1) and (2), read and interpret /etc/ld.so.conf
(but this isn't trivial because it usually includes references to other files or wildcards of directory contents). You may also parse output of ldconfig -p
and accumulate listed directories. But beware of possible conflicts with existing libraries and of need to remake ldconfig cache after changing library set.
Answered by Netch on October 31, 2021
Usually you can get this information by reading /etc/ld.so.conf
. That file may include other files; on my system, it includes all files in /etc/ld.so.conf.d
.
Note that there are multiple directories that will be searched. Note also that this does not affect the path of the dynamic linker, ld.so
, which is embedded in the binary and is usually uniform for a given architecture and ABI.
Answered by bk2204 on October 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP