Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find the full file path given a library name like libfoo.so.1?

Tags:

c

linux

linker

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.

like image 213
Lekensteyn Avatar asked Oct 30 '12 22:10

Lekensteyn


People also ask

How do I find the library path in Linux?

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.

What is Lib path?

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 in Linux?

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.

What is Ldconfig in Linux?

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.


1 Answers

Use ldconfig which is the tool that manages link space.

The -p flag lets you browse all available linkable libraries.

like image 183
HonkyTonk Avatar answered Oct 04 '22 07:10

HonkyTonk