How to list shared library dependencies used by an application

June 15th, 2008 mysurface Posted in Developer, ldd | Hits: 200435 | 11 Comments »

Almost every application in Linux uses shared library, even the one compiled by yourself with gcc. You may have realized that application compiled with gcc 4.1 in Fedora or Ubuntu does not able to run under Red Hat ES3 or ES4. Or some other new applications does not able to run at legacy Linux, it is all because of missing shared library dependencies.

Is there any work around solution to allow legacy Linux uses new version of application?
My guess is as long as we resolved those dependencies completely, the application should works under any linux platform, unless the application or its dependencies required kernel version are not match.

Is there any ways to know what shared library are used by a specific application?
We can use ldd. Lets take a simple application for example. I have wrote a fun app uses ncurses library, its call “matrix”. It does nothing but simulate the running characters flow from top to bottom in the movie matrix at your linux console. You may get the source code as well as the binaries at HERE.

ldd matrix =>  (0x00110000) => /lib/ (0x00111000) => /usr/lib/ (0x0793a000) => /lib/ (0x0056e000) => /lib/ (0x0790d000) => /lib/ (0x00413000) => /lib/ (0x00599000) => /lib/ (0x00ad0000)
        /lib/ (0x003f4000)

Observed that, it uses You may find this file in /usr/lib, /usr/share/lib or /lib. Bear in mind, probably is just a symbolic link, you need to copy the real .so instead of its symlink.

The shared library itself sometimes also have dependencies too, which it may also use some other shared library, to fully resolved that, we can add verbose to ldd for more details.

ldd -v matrix

       (GLIBC_2.1) => /lib/
       (GLIBC_2.0) => /lib/
       (GLIBC_2.1.3) => /lib/
       (GLIBC_2.4) => /lib/
       (GLIBC_2.3) => /lib/
       (GLIBC_2.1) => /lib/
       (GLIBC_2.3.4) => /lib/
       (GLIBC_2.0) => /lib/

It seems my ncurses lib uses libdl and glibc.

11 Responses to “How to list shared library dependencies used by an application”

  1. Nice post.
    Could you explain more about the version of GLIBC? why same shared library depends on multiple different version GLIBC?


  2. You failed to mentioned that one must change directory to the location of a program in question. For example,

    ~$ cd /usr/bin
    /usr/bin$ ldd -v nano

  3. Or provide a full path, i.e.

    ~$ ldd -v /usr/bin/nano

  4. @James: GLIBC has to be backward compatible, it includes object symbols of various version.

    @Al: You may want to use which,
    ldd -v `which nano`

  5. which command will list share libraries used by KDE application kpand

  6. @matthew
    ldd `which kpand`

  7. From just under the ‘ldd matrix’ code block:

    “Bare in mind,..” ??

    You asked us to get our minds naked, dude.

    The verb bare means “to expose, to uncover,” as in ‘She accidentally bared her breasts at the pool’.

    The verb bear means “to carry, to bring forth, to take along,” and the like, as in ‘Bear with me’.

    The noun bear is the animal.

    A common error in an otherwise excellent writeup; see “duel v. dual” for more hilarity.

  8. Omg, haha. It is a typo, I corrected. Thanks Elisa, and please bear with me :)

  9. hi! One problem is when one crucial library is missing, then ldd only says: No such file or directory, but NOT which library that is missing.

  10. Hi,

    I have a situation where one depended other file and i want to move dependency to some other folder.
    will will refer from that folder or is their any way to modify .so file.


  11. Lenovo offers absorbed Motorola with the closing of its $2.91bn purchase from Google of the Android phone maker.

Leave a Reply