[Previous entry: "Seeing is Believing"] [Main Index] [Next entry: "Success!"]
04/03/2003 Entry: "Linking Hell"
Linking Hell
So I'm trying to find a missing symbol and match it to the proper library so I can include it in my Makefile, and when I run 'nm' on the directory, it doesn't tell me which file has the right symbol! So, I wrote a script to do it. It's a Bourne Shell script since the system I'm on is ancient and annoying, but that also means this should run anywhere.
Make sure you strip out any ^Ms before you run your script! Unix hates ^Ms.
#!/bin/sh
# Program: symsearch
# Function: This script searches library files for a desired symbol
# and prints out any matched symbols along with the file
# it came from.
# Author: Spastic Mutant
# mutant@spasticmutant.com
#
# usage: symsearch
# First argument: symbol to search for, e.g. sem_wait
# Second argument: list of library files (.a or .so) to search
#
# Example: symsearch sem_wait *.so
# searches all library files in the path with the suffix .so
# for the symbol 'sem_wait'.
firstarg=$1
shift
echo Searching for $firstarg:
for i in $* ;
do
nm $i | grep $firstarg
if [ "$?" -eq "0" ]; then
echo Found symbol $firstarg in file $i
fi
done
|
DISCLAIMER: This web page
was constructed with 100% recycled electrons (or, during shortages, at
least 35% post-consumer electrons). No electrons were harmed in the making
of this web page, although several were accelerated against their
collective will. No files have been charged. And Remember: the only Good
Cow is a Dead Cow. © 2000, 2001, 2002 Spastic Mutant Productions. All Rights Reserved. |