libpqxx 配置找不到用于本地安装 PostgreSQL 的 libpq-fe.h

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

我正在计算集群 运行 Red Hat 6.6 Linux 上生成构建脚本,访问受限 sudo。目前,我一直在从 GitHub 上的源代码创建 PostgreSQL 10.10 的本地安装。在构建之后,它们安装在 /storage/home/work/build_env/postgres 并更新 $PATH 以便 pg_config 运行并且 pkg-config libpq --cflags returns

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

正在从 GitHub 源克隆 libpqxx,但卡在配置中并出现以下错误:

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.

但是,在 pkg-config returns 的目录中,我看到了以下内容:

[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

配置脚本找不到文件可能导致此问题的原因是什么?


错误实际上从日志中非常明显,但也很微妙。如问题中所述,该文件存在于正确的路径中;但是,脚本中有多余的 white-space:

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

应该是:

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

这可以通过使用 sed 使用模式 sed 's/ *$//g' 去除白色 space 来纠正。这可以通过更新配置脚本 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')

这个问题已经addressed in the libpqxx repository,所以如果遇到问题,规范的解决方案是升级到最新版本的源代码。