I can't link my program with shared library located in non-standart OSX lib directory. I've got this library from MacPorts and it's located in /opt/local/lib:
$ ls /opt/local/lib/libgmp*
/opt/local/lib/libgmp.10.dylib /opt/local/lib/libgmpxx.4.dylib
/opt/local/lib/libgmp.a /opt/local/lib/libgmpxx.a
/opt/local/lib/libgmp.dylib /opt/local/lib/libgmpxx.dylib
/opt/local/lib/libgmp.la /opt/local/lib/libgmpxx.la
I've found that one can use DYLD_FALLBACK_LIBRARY_PATH, but it not works for me:
$ DYLD_LIBRARY_PATH=/opt/local/lib gcc ab.c -lgmp
ld: library not found for -lgmp
collect2: ld returned 1 exit status