Subject: Re: library dependencies ?
To: Space Case <>
From: Frederick Bruckman <>
List: current-users
Date: 06/02/2001 20:00:30
On Sat, 2 Jun 2001, Space Case wrote:

> On Jun 2,  5:05pm, wrote:
> >On Sat, Jun 02, 2001 at 04:13:02PM -0700, Space Case wrote:
> >> Does anyone have/know of a tool that can check the library dependencies of
> >> executables, and flag those whose libraries are missing?
> >if you use ksh or bash, you could do something like:
> >
> >find $(echo $PATH|tr : ' ') | while read f; do ldd "$f" 2>/dev/null |\
> >	grep 'curses\.so\.[23]' 2>&1 >/dev/null; \
> >	if [ $? -eq 0 ]; then echo $f; fi; done

The $PATH thing is clever. It still misses executables in
/usr/*/libexec, /usr/X11R6/qt?/bin, and no doubt a few other places
(but my first try did no better).

The "if [ $? -eq 0 ]; ... fi" is unnecessary, when you can just use

> Oh, I rather like that.  Now I just have to decide whether I want to run
> it for each of the 22 libs that have old majors, or try to shoehorn it all
> into the one grep command. ;-)

Just search for the string "not found". On i386, this unfortunately
picks up linux executables, but that shouldn't be a problem for you.

Here's a shell function that should work with sh or bash (but I've
only tested it with /usr/bin/ksh)...

find_broke ()
    for e in $@
        ldd $e 2> /dev/null |
        grep -q "not found" &&
        echo $e

After executing the above, assuming you know where your executables
are, you can search for broken ones with

    find_broke /usr/local/bin/* /usr/local/sbin/*

or even

    find_broke /usr/local/bin/\* /usr/local/sbin/\*


    find_broke "/usr/local/bin/* /usr/local/sbin/*"

if expanding all the wildcards at once causes the shell to balk.