There is a brute-force method I sometimes use, but you do have to know what directories to look in for the library you need (/lib, /usr/lib and /usr/local/lib are the usual suspects). I've created a shell script I call "gnm," (short for "grep nm," the two utilities it uses) with the below contents. If you create such a text file, remember to make it executable (chmod +x gnm).
#!/bin/sh
if [ $# -lt 2 ] ; then
echo Usage: $0 pattern file[s]
exit
fi
pattern=$1
shift
while [ $# -gt 0 ] ; do
nm $1 | grep $pattern > /dev/null
if [ $? -eq 0 ] ; then
echo $1
fi
shift
done
When I'm searching for a library that defines a particular symbol, I issue a command something like:
gnm symbol /usr/lib/*.a
For example, the source you mentioned gives me the following link errors:
boost_example.cpp:(.text+0x38): undefined reference to `boost::system::get_system_category()'
boost_example.cpp:(.text+0x44): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x50): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x5c): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x68): undefined reference to `boost::system::get_system_category()'
so I use the command:
gnm get_system_category /usr/lib/*.a
which reports:
/usr/lib/libboost_filesystem.a
/usr/lib/libboost_system.a
Trying the first of these results in the same errors, but the second one works:
g++ boost_example.cpp -lboost_system -o run
I don't know why I needed the system library where you needed filesystem; maybe different versions of Boost.