#!/bin/bash # Copyright 2009-2010 Gilbert Ashley # re-written from an idea by # Ricardo Garcia Gonzalez. # His version needed bash-4, awk, cat, cut, grep and tr -plus objdump # This only needs bash >=3.0 and objdump :-) # I added the "not found" report # version 0.1 if [[ -n $1 ]] ; then declare MY_LIBS="$(objdump -p $@ |grep NEEDED)" # Library directories. LIBDIRS=${LD_LIBRARY_PATH//:/ }"/lib$LIBDIRSUFFIX /usr/lib$LIBDIRSUFFIX" if [[ -r /etc/ld.so.conf ]] ; then while read LINE ; do LIBDIRS=${LIBDIRS}" $LINE" done < /etc/ld.so.conf fi #LIBDIRS=${LIBDIRS}${LD_LIBRARY_PATH//:/ } for LINE in $(echo $MY_LIBS) ; do HAVE_LIB=0 if [[ $LINE != "NEEDED" ]] ; then for LIBDIR in $LIBDIRS ; do if [[ -e "$LIBDIR/$LINE" ]] ; then # don't use '-x' which requires the lib to be executable HAVE_LIB=1 echo "$LIBDIR/$LINE" # for an output more like the real ldd: # echo "$LINE => $LIBDIR/$LINE" break else continue fi done if [[ $HAVE_LIB != 1 ]] ; then echo "$LINE"" not found" # for an output more like the real ldd: # echo "$LINE => not found" fi fi done fi