Viewing shared library search order

When debugging library search path problems, it is often useful to see which libraries are used, and the order in which they are accessed. This is easily accomplished with the Solaris ldd(1m) utilities “-s” option:

$ ldd -ss /usr/sfw/bin/wget |more

   find object=libsocket.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libsocket.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libsocket.so.1
        libsocket.so.1 =>        /usr/lib/libsocket.so.1

   find object=libnsl.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libnsl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libnsl.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1

   find object=libc.so.1; required by /usr/sfw/bin/wget
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1
        libc.so.1 =>     /usr/lib/libc.so.1

   find object=libnsl.so.1; required by /usr/lib/libsocket.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libnsl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libnsl.so.1

   find object=libc.so.1; required by /usr/lib/libsocket.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   find object=libdl.so.1; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libdl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libdl.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1

   find object=libc.so.1; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   find object=libmp.so.2; required by /usr/lib/libnsl.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libmp.so.2
    search path=/usr/lib  (default)
    trying path=/usr/lib/libmp.so.2
        libmp.so.2 =>    /usr/lib/libmp.so.2

   find object=libdl.so.1; required by /usr/lib/libc.so.1
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libdl.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libdl.so.1

   find object=libc.so.1; required by /usr/lib/libmp.so.2
    search path=/usr/local/lib  (LD_LIBRARY_PATH)
    trying path=/usr/local/lib/libc.so.1
    search path=/usr/lib  (default)
    trying path=/usr/lib/libc.so.1

   object=/usr/lib/libc.so.1; filter for /usr/platform/$PLATFORM/lib/libc_psr.so.1

   find object=/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1; required by /usr/lib/libc.so.1
        /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1

   object=/usr/lib/libdl.so.1; filter for /usr/lib/ld.so.1

I find this useful for finding references to outdated libraries, and libraries that are not located in standard locations (e.g., /usr/lib).

Leave a Comment