rjzii
rjzii

Reputation: 14533

libpqxx configure cannot find libpq-fe.h for local install of PostgreSQL

I'm in the process of generating a build script on a compute cluster running Red Hat 6.6 Linux with restricted sudo access. Presently I've been creating a local install of PostgreSQL 10.10, from the sources on GitHub. Following the build they are installed at /storage/home/work/build_env/postgres and the $PATH is updated so that pg_config runs and pkg-config libpq --cflags returns

-I/storage/home/work/build_env/postgres/include

libpqxx is being cloned from the GitHub source, but is getting stuck at configuration with the following error:

configure: using PostgreSQL headers at /storage/home/work/build_env/postgres/include
configure: using PostgreSQL libraries at /storage/home/work/build_env/postgres/lib
checking /storage/home/work/build_env/postgres/include  /libpq-fe.h usability... no
checking /storage/home/work/build_env/postgres/include  /libpq-fe.h presence... no
checking for /storage/home/work/build_env/postgres/include  /libpq-fe.h... no
configure: error:
Can't find libpq-fe.h in /storage/home/work/build_env/postgres/include  .  Are you sure the libpq
headers are installed correctly?  They should be in the directory returned by
"pg_config --includedir" or "pkg-config libpq --cflags".

If you do have libpq (the C-language client library for PostgreSQL) installed,
make sure you have the related development materials--mainly its header files--
as well as the library binary.  Some system distributions keep the two in
seperate packages with names like "alibrary" and "alibrary-dev", respectively.
In that case, make sure you have the latter installed as well.

However, looking in the directory that pkg-config returns I see the following:

[user@compute libpqxx]$ ls -al /storage/home/work/build_env/postgres/include | grep libpq
drwxrws---  2 user user_collab  4096 Nov  7 13:35 libpq
-rw-r--r--  1 user user_collab  2211 Nov  7 13:35 libpq-events.h
-rw-r--r--  1 user user_collab 22179 Nov  7 13:35 libpq-fe.h

What could be causing this issue with the file not being found by the configuration script?

Upvotes: 1

Views: 733

Answers (1)

rjzii
rjzii

Reputation: 14533


The error is actually quite obvious from the logs, but subtle as well. As noted in the question, the file exists at the correct path; however, the script has superfluous white-space in it:

/storage/home/work/build_env/postgres/include  /libpq-fe.h 

when it should be:

/storage/home/work/build_env/postgres/include/libpq-fe.h

This is correctable by stripping the whitespace using sed using the pattern sed 's/ *$//g'. This can be done by updating the configure script in situ:

19006 -  with_postgres_include=$($PKG_CONFIG libpq --cflags | sed 's/^-I//')
19006 +  with_postgres_include=$($PKG_CONFIG libpq --cflags | sed 's/^-I//' | sed 's/ *$//g')

This issue has been addressed in the libpqxx repository, so the canonical solution would be to upgrade to the latest version of the source code if the problem is encountered.

Upvotes: 4

Related Questions