How to get the system library path on Unix (Linux, FreeBSD)
Asked Answered
P

1

7

I need a more-or-less portable programmatic way for querying the dynamic library path list. For Linux, I can concatenate the $LD_LIBRARY_PATH and the contents of /etc/ld.so.conf (processing the include directives as needed and possibly filtering by architecture), but that doesn't work e.g. on FreeBSD.

Ultimately, I need a Python function for doing that. It can call gcc or other external commands if needed.

Pelops answered 9/2, 2010 at 16:5 Comment(0)
A
6

For both Linux and FreeBSD you can try working through the output of ldconfig(8). The options for listing the libraries are different though (-p on Linux, -r on FreeBSD.) Hope this helps.

Edit:

Solaris is different - see man crle.
Mac OSX is different yet again - see man dyld.

Anderaanderea answered 9/2, 2010 at 16:13 Comment(2)
Do you have anything for other Unix systems, like the Mac OS X or Solaris?Pelops
I believe OSX should be pretty close to FreeBSD, while Solaris should be similar to Linux. Hmmm ... not exactly - updating the post.Anderaanderea

© 2022 - 2024 — McMap. All rights reserved.