Use ldd to see which dynamic libraries a binary is linked against.
ldd
You can edit /etc/ldd.so.conf to update the directories that are searched when compiling programs.
/etc/ldd.so.conf