Without implementing a linker or using ldd
, how can I find the full path to a library? Is there a standard library available for that on Linux? (POSIX maybe?)
Using ldd
and grep
on a file that is knowingly using libGL.so.1
, it looks like:
$ ldd /usr/bin/glxinfo | grep libGL libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f34ff796000)
Given a library name like libGL.so.1
, how can I find the full path /usr/lib/libGL.so.1
?. Preferably accepting an option for finding 32-bit and 64-bit libraries. If no library does that, does a program exist to do this? Something like find-library-path libGL.so.1
. The locate libGL.so.1
command does not count.
I don't want to actually load the library using dlopen
or something if it executes code from that library.
By default, libraries are located in /usr/local/lib, /usr/local/lib64, /usr/lib and /usr/lib64; system startup libraries are in /lib and /lib64. Programmers can, however, install libraries in custom locations. The library path can be defined in /etc/ld.
The LIBPATH environment variable tells the shell on AIX® systems which directories to search for dynamic-link libraries for the INTERSOLV DataDirect ODBC Driver. You must specify the full path name for the directory where you installed the product.
How do I set the Library path under Linux operating systems? You need to use ldconfig config file and ldconfig command which creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld. so.
ldconfig is a utility that indexes shared object names to simplify loading on shared object libraries by executables. It scans standard directories and those found in the ld. so. conf configuration file and stores its index in ld.
Use ldconfig which is the tool that manages link space.
The -p
flag lets you browse all available linkable libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With