I've recently had to upgrade from Postgres version from 10 to 11 with homebrew
on my macOS Mojave and because of the need to use Postgis it looks not so trivial to follow the standard way of using brew postgresql-upgrade-database
after upgrading Postgres version.
I've found this gist that looks pretty much as a probable solution for my problem. When I try to run make
on the postgis-2.5.1
it throws an error that seems like it confuses the Command Line Tools
with the Xcode
path, which I currently don't have installed.
Below I paste the sequence of commands I've tried so far:
❯ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
❯ ./configure --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4
❯ make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
echo "---- Making all in ${s}"; \
/Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I../liblwgeom -g -O2 -I../libpgcommon -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1
Even if I explicitly set the sysroot
path on ./configure
or set CMAKE_OSX_SYSROOT
before issuing make
it won't work.
❯ ./configure --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/ --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4
❯ CMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
echo "---- Making all in ${s}"; \
/Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I../liblwgeom -g -O2 -I../libpgcommon -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1
For the record, I've already installed macOS_SDK_headers_for_macOS_10.14.pkg
I've found here and here that it might be required.
I'd really appreciate any clues or tips on what I might be doing wrong or any other approaches that could fix the problem.
Thanks!