postgreSQL Compilation and linking
During compilation, you have to add the PostgreSQL include directory, which can be found with pg_config --includedir, to the include path.
You must link with the PostgreSQL client shared library (libpq.so on UNIX, libpq.dll on Windows). This library is in the PostgreSQL library directory, which can be found with pg_config -- libdir.
Note: For historical reason, the library is called libpq.soand not libpg.so, which is a popular trap for beginners.
Given that the below code sample is in file coltype.c, compilation and linking would be done with
gcc -Wall -I "$(pg_config --includedir)" -L "$(pg_config --libdir)" -o coltype coltype.c -lpq
with the GNU C compiler (consider adding -Wl,-rpath,"$(pg_config --libdir)" to add the library search path) or with
cl /MT /W4 /I <include directory> coltype.c <path to libpq.lib>
on Windows with Microsoft Visual C.