Hm, is there a libpq dylib in /usr/lib? If so, maybe it's capturing the reference? "otool -L main" would be informative about which dylib is actually getting called, I think. If it's not what you expected, the lack of a -L switch in your link command is probably the reason.
regards, tom lane
Here is the output for otool -L for both.
Static libpq.a
main:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
Dynamic libpq.5.4.dylib using -lpq
main:
libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
Dynamic libpq.5.4.dylib using the command from the previous email (This one is interesting because /usr/local/pgsql doesn't exist on this machine)
main:
/usr/local/pgsql/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
I did have a libpq.5.dylib in /usr/lib and it turns out that that was the problem. So it looks like, even though I was specifying the library, it just picked the one at /usr/lib version anyway. (I obviously have much more to learn about how the linker works on OS X)
The solution was to move the Enterprise DB libpq.5.4.dylib into /usr/lib (and create associated symlinks) and it worked correctly after that.