Skip to content

Instantly share code, notes, and snippets.

@skissane
Last active June 14, 2022 14:17
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save skissane/0487c097872a7f6d0dcc9bcd120c2ccd to your computer and use it in GitHub Desktop.
Save skissane/0487c097872a7f6d0dcc9bcd120c2ccd to your computer and use it in GitHub Desktop.
Solutions and workarounds for issues with "pex install postgis" (assuming macOS+Homebrew)

Problem: configure: error: could not find libxml2
Solution: sudo xcode-select -s /Library/Developer/CommandLineTools

Problem: configure: error: could not find geos-config within the current path. You may need to try re-running configure with a --with-geosconfig parameter
Solution: brew install geos

Problem: configure: error: could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir
Solution: brew install proj and then CFLAGS=-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H pex install postgis

Problem: configure: error: gdal-config not found. Use --without-raster or try --with-gdalconfig=<path to gdal-config>
Solution: brew install gdal

Problem: lwin_geojson.c:36:10: fatal error: 'json-c/json_object_private.h' file not found
Hacky workaround: touch /usr/local/include/json-c/json_object_private.h

(Note: json_object_private.h is a private header file, and postgis should not include it. Newer json-c versions no longer ship it. Newer postgis versions this is fixed. Creating an empty file is enough to get past this error.)

Problem: ../liblwgeom/liblwgeom.h:35:10: fatal error: 'proj_api.h' file not found
Solution: PG_CPPFLAGS='-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I/usr/local/include' CFLAGS='-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I/usr/local/include' pex install postgis

see: petere/pex#8

Problem: address_parser.c:10:10: fatal error: 'pcre.h' file not found
Ultra-hacky workaround: ln -s /usr/local/include/pcre*.h /usr/local/opt/postgresql@9.6/include

Can't really defend this monstrosity except to say it works, and I haven't found any better solution. If anyone knows of a less stupid solution, I'm all ears!

@ludo
Copy link

ludo commented Jun 17, 2019

Thanks for posting this! You saved me from wasting a couple hours of my life debugging this after Homebrew updated some of my dependencies... GIS dependencies are a virtual house of cards.

I only ran into the liblwgeom.h:35:10 and the address_parser.c:10:10 errors. Only difference was that for whatever reason it had non-existing folders listed for postgresql when I tried to compile so it still couldn't find the pcre headers after symlinking them.

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/usr/local/Cellar/geos/3.7.2/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2     -g -O0 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.13/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.13/include/internal -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 address_parser.o address_parser.c
address_parser.c:10:10: fatal error: 'pcre.h' file not found
#include <pcre.h>
         ^~~~~~~~
1 error generated.

So instead I symlinked the pcre header files to the geos directory:

ln -s /usr/local/include/pcre*.h /usr/local/Cellar/geos/3.7.2/include

🤷‍♂️

Thanks again!

@digi0ps
Copy link

digi0ps commented Jul 22, 2020

This helped me install it after struggling for a day. Thanks a lot. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment