If you are building with --with-pgsql=/some/dir, make sure that you still have libpq loaded up by ldconfig. I compiled and installed postgres from the tarball and then had to manually create the symlinks in /usr/local/lib. In particular, after you have built and installed postgres, you need to do the following (presuming you installed to /usr/local/pgsql):
# cd /usr/local/lib
# ln -s ../pgsql/lib/libpq.so.2.1 libpq.so.2.1
# ln -s ../pgsql/lib/libpq.so.2.1 libpq.so.2
# ln -s ../pgsql/lib/libpq.so.2.1 libpq.so
# ldconfig
/usr/local/lib needs to be listed in /etc/ld.so.conf, but it should already be there on most systems. The above notes all apply to Linux only, but may be useful on other platforms as well.
--sam