From the Apple documentation:
Before you can use a dynamic library as a dependent library, the library and its header files must be installed on your computer.
The standard locations for header files are (not always needed):
~/include
/usr/local/include
/usr/include
The standard locations for dynamic libraries (dylib files) are:
~/lib
/usr/local/lib
/usr/lib.
You may also place the .dylib file at a nonstandard location in your file system, but you must add that location to one of these environment variables:
LD_LIBRARY_PATH
DYLD_LIBRARY_PATH
DYLD_FALLBACK_LIBRARY_PATH
So in short, this is what I do when developing an application that needs a dylib:
1) For the development process, I copy the dylib file to ~/lib - This way my IDE (Lazarus Pascal) can find the dylib.
2) When testing for deployment, I remove the dylib from ~/lib, so I can test if I added the dylib correctly in the .app bundle.
Typically I create 2 scripts for that (MySQL client dylib example):
install-dylib.sh
mkdir ~/lib
cp libmysqlclient.20.dylib ~/lib
cd ~/lib
ln -s libmysqlclient.20.dylib libmysqlclient.dylib
and
uninstall-dylib.sh
rm ~/lib/libmysqlclient.dylib
rm ~/lib/libmysqlclient.20.dylib
Don't forget to do
chmod +x install-dylib.sh
chmod +x uninstall-dylib.sh
Also note that in the install script, I do a symbolic link to a generic name (no version number).