The -l option causes the linker to search for libraries in /usr/lib. If you specify -lmysql, it will look for /usr/lib/libmysql.a or /usr/lib/libmysql.dylib. If neither of these is present, you will need to install one of them. If the library is in a different path, /usr/share/pgsql/lib for example, you will have to specify an additional search path with the -L option: -L /usr/share/pgsql/lib. If you use Xcode, both options are automatically added when you add the library using Project>Add Files.
If you really have no clue which library an API is present in, you can run the command 'nm -o /usr/lib/* | grep SomeMissingAPI' to attempt to find it, though this does not search Frameworks, and you will have better luck searching Apple's developer documentation for it.