Linux modules and libraries

Dynamically linked libraries are linked and loaded at run time, either by “” or “”, depending on how it was compiled: in a.out or ELF format.

Every program whenever they need a library, look through a known list of places to find the needed library. One place they look is “/etc/”, which contains an ordered list of libraries to be searched for the needed module.

To find the libraries needed for a program, use the command “ldd”

# ldd /usr/bin/gimp => (0x00110000) => /usr/lib/ (0x04b9a000) => /usr/lib/ (0x00a7a000) => /usr/lib/ (0x00a6d000) => /usr/lib/ (0x00264000) => /usr/lib/ (0x00a1e000) => /usr/lib/ (0x00a5d000) => /usr/lib/ (0x00a07000) => /usr/lib/ (0x06192000) => /usr/lib/ (0x06532000) => /usr/lib/ (0x005fd000) => /usr/lib/ (0x00430000) => /usr/lib/ (0x06169000) => /lib/ (0x00bff000) => /usr/lib/ (0x00425000) => /usr/lib/ (0x0049e000) => /lib/ (0x00710000) => /lib/ (0x0098c000) => /usr/lib/ (0x0040c000) => /usr/lib/ (0x00449000) => /usr/lib/ (0x005b9000) => /lib/ (0x001ad000) => /lib/ (0x00c2a000) => /usr/lib/ (0x00dce000) => /usr/lib/ (0x00111000) => /usr/lib/ (0x0082f000) => /lib/ (0x00854000) => /lib/ (0x00375000) => /lib/ (0x001c3000) => /lib/ (0x00c46000) => /lib/ (0x00aa9000) => /usr/lib/ (0x00c6d000) => /usr/lib/ (0x0019b000) => /usr/lib/ (0x00d71000) => /usr/lib/ (0x001a0000) => /usr/lib/ (0x001a9000) => /usr/lib/ (0x00493000) => /usr/lib/ (0x001b0000) => /usr/lib/ (0x001b7000) => /lib/ (0x00c31000)
/lib/ (0x00a8a000) => /lib/ (0x00d83000) => /lib/ (0x00814000) => /lib/ (0x00a29000) => /usr/lib/ (0x00c68000) => /usr/lib/ (0x00c60000)

———————————————————————— contains a complete list of all the shared object libraries that or will search in machine readable format.

Suppose that I install a new application in my machine. I also add a library, say, needed for that application under the location /usr/local/lib/XYZ/lib/ directory. But if “/etc/ file doesn’t contain a reference to that directory, the library will never get into the cache “/etc/”, and “” and “” will never be able to access that library from cache for running the newly installed application.

How to fix the above said problem?

Simple. Add the directory “/usr/local/lib/XYZ/lib/” to the “/etc/” file and then – as root – run the “ldconfig” program so it rebuilds the cache “/etc/”.

To view the contents of “” use the command “ldconfig -p”. This will give the output with the following kind of first line “1301 libs found in cache `/etc/'”

On Linux, run “/sbin/ldconfig -v” as root to see all the shared libraries that applications make use of day in and day out

If you need further assistance, please do not hesitate to contact us.