Q: pg_config not found when building PostGIS source on Windows I am trying to build the latest stable PostGIS from source on Windows using this documentation. I already have PostgreSQL installed without problems. When I execute the configure script from the PostGIS source, I get this problem:

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

I get this problem if I specify the pg_config file using 
$ 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

but it does exist...
Does anyone have any suggestion? It is important that I build from source.

A: It is a bug in configure.
You can see that from this error message:
./configure: line 15593: test: "C:\Program: binary operator expected

On that line, I see in configure:
if test -f $PG_CONFIG; then

There should be double quotes around that (and other references to PG_CONFIG).
I can think of two workarounds:


*

*Install PostgreSQL in a directory without spaces in the path name.

*Unpack PostGIS in a directory under C:\Program Files and run configure like this:
./configure --with-pgconfig="../PostgreSQL/9.6/bin/pg_config.exe"

A fix has been committed to PostGIS, so it should work from release 2.4.0 on.
