[asterisk-users] How to check currently used libraries from command line ?

A J Stiles asterisk_list at earthshod.co.uk
Mon Jan 16 04:43:38 CST 2012


On Monday 16 January 2012, Olivier wrote:
> Hi,
> 
> I've recently upgraded a system from 1.8 to asterisk 10 and also
> updated spandsp while doing so.
> I wondered what is the safest and easiest way to check from command
> line which libraries a running Asterisk system is currently using
> (just like "dahdi show version", for instance).
> 
> Though I'm currently asking this for spandsp, this question is on a
> more general plan (for example, which ssl library am I currently using
> ?).

To find out which libraries a particular binary executable program is linked 
against, you just need to do

$ ldd /path/to/executable

You can find the actual path to an executable by typing

$ which foo

Replace foo by the name of the executable about which you want information, 
obviously.

Now, because we usually want the computer to do as much of the hard work for 
us as possible, we can use the $(command) operator -- which treats whatever is 
between the brackets as a command, runs it and substitutes its output into the 
command which it was part of -- to combine these two commands into one:

$ ldd $(which foo)

i.e. it will run "which foo", and then do "ldd" on whatever output "which foo" 
returned.

Trivial example below:

$ ldd $(which ls)
        linux-vdso.so.1 =>  (0x00007fffa7974000)
        libselinux.so.1 => /lib/libselinux.so.1 (0x00007fdc03188000)
        librt.so.1 => /lib/librt.so.1 (0x00007fdc02f80000)
        libacl.so.1 => /lib/libacl.so.1 (0x00007fdc02d78000)
        libc.so.6 => /lib/libc.so.6 (0x00007fdc02a17000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007fdc02813000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fdc033ce000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007fdc025f6000)
        libattr.so.1 => /lib/libattr.so.1 (0x00007fdc023f2000)

Hmm, that's a whole lot of libraries just to get a directory listing!  Not 
surprisingly, busybox gets away with rather less:

$ ldd $(which busybox)
        linux-vdso.so.1 =>  (0x00007fff2b7ff000)
        libm.so.6 => /lib/libm.so.6 (0x00007f04a8217000)
        libc.so.6 => /lib/libc.so.6 (0x00007f04a7eb6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f04a84c1000)

Note1:  Here we see 16 hex digits after each library name, indicating a 64-bit 
system.  On a 32-bit system, we would see only 8 hex digits after each library 
name.

Note2:  Programs that sometimes or always crash, may be missing a library.  If 
so, this will be obvious when you run ldd.

-- 
AJS

Answers come *after* questions.



More information about the asterisk-users mailing list