pg_config 在 Windows 上构建 PostGIS 源时未找到

pg_config not found when building PostGIS source on Windows

我正在尝试使用 this 文档从 Windows 上的源代码构建最新的稳定 PostGIS。我已经毫无问题地安装了 PostgreSQL。当我从 PostGIS 源执行配置脚本时,我遇到了这个问题:

configure: error: could not find pg_config within the current path. You may need to re-run configure with a --with-pgconfig parameter.

如果我使用

指定 pg_config 文件,我就会遇到这个问题
$ sh ./configure --with-pgconfig="c:/Program Files/PostgreSQL/9.6/bin/pg_config.exe"

configure: error: the user-specified pg_config file c:/Program Files/PostgreSQL/9.6/bin/pg_config.exe does not exist

但它确实存在...

有人有什么建议吗?我从源代码构建很重要。

这是 configure 中的错误。

从这个错误信息可以看出:

./configure: line 15593: test: "C:\Program: binary operator expected

在那条线上,我在 configure 中看到:

if test -f $PG_CONFIG; then

应该用双引号将其括起来(以及对 PG_CONFIG 的其他引用)。

我可以想到两个解决方法:

  • 在路径名中没有空格的目录中安装 PostgreSQL。

  • C:\Program Files 和 运行 configure 下的目录中解压 PostGIS,如下所示:

    ./configure --with-pgconfig="../PostgreSQL/9.6/bin/pg_config.exe"
    

一个 fix has been committed 到 PostGIS,所以它应该从 2.4.0 版本开始工作。