1

I want to run a Unix program which runs for a few seconds, without sacrificing speed of execution. After it is done, I would like to know what dynamic (shared) libraries it used.

What is the appropriate command?

The main problem is that I have a handful of BLAS implementations, and I want to figure out exactly which one is being used by each of a handful of different programs.

Joseph Turian
  • 265
  • 2
  • 7

3 Answers3

4

Using ldd you can see the dynamic libraries that are linked to a specific binary file.

Like so:

$ ldd /usr/bin/wget
    linux-vdso.so.1 =>  (0x00007fffa5dff000)
    libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f4d3280e000)
    libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f4d3247e000)
    libdl.so.2 => /lib/libdl.so.2 (0x00007f4d32279000)
    librt.so.1 => /lib/librt.so.1 (0x00007f4d32071000)
    libc.so.6 => /lib/libc.so.6 (0x00007f4d31cef000)
    libz.so.1 => /lib/libz.so.1 (0x00007f4d31ad7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4d32a73000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f4d318ba000)
Weboide
  • 3,275
  • 1
  • 23
  • 32
3

Lastly, you could use strace. strace <program_to_execute will give you a ton of info, including calls to libraries. It's not nearly as clean as the other answers, but it's another way of doing things. (and useful in its own right)


--Christopher Karel

Christopher Karel
  • 6,442
  • 1
  • 26
  • 34
2

In addition to ldd, cat /proc/$pid/maps will show you which libraries have been mapped into memory, including dynamic ones loaded after program start (and deleted items too)

Jason
  • 1,875
  • 1
  • 13
  • 12
  • I should add, the program needs to be running -- you mention your runs are only a few seconds, you may need to suspend your program, or just be quick w/ the cat /proc/$pid/maps – Jason Jun 23 '10 at 02:07