ldd

Use ldd to see which dynamic libraries a binary is linked against.

You can edit /etc/ldd.so.conf to update the directories that are searched when compiling programs.