You need to add -lpq
as an option to GCC to link the libpq
itself. It has to go after -lpqxx
:
g++ test.cpp -lpqxx -lpq -I/usr/local/include -I/usr/local/pgsql/include
# ^^^^ here
This is needed as libpqxx
is just a C++ wrapper around the C interface of libpq
which is the real client library for PostgreSQL. You might need to add -L/path/to/libpq
before the -lpq
in case it is not found in the system's library path(s).