Trouble compiling PostGIS on macOS due to missing headers and configuration files, specifically with PostgreSQL 16

75 Views Asked by At

Question: I'm currently facing challenges while attempting to compile PostGIS 3.4.0 on macOS (version 12.0.1). The primary issue arises from missing headers and configuration files, particularly in conjunction with PostgreSQL 16. Here's the specific error message I encounter during the compilation process:

configure: error: Could not find header: json.h

Here's the breakdown of my setup:

  • Operating System: macOS 12.7.3 Monterey
  • PostGIS Version: 3.4.0
  • Dependencies:
    • proj: Installed via Homebrew at /usr/local/opt/proj
    • protobuf-c: Installed via Homebrew at /opt/homebrew/opt/protobuf-c
    • PostgreSQL 16: Installed via Homebrew at /usr/local/Cellar/postgresql@16/16.2_1
    • json-c: Installed via Homebrew at /usr/local/Cellar/json-c/0.17
    • sfcgal: Installed via Homebrew at /usr/local/Cellar/sfcgal/1.5.1_1
    • pcre: Installed via Homebrew at /opt/homebrew/opt/pcre

Here are the steps I've taken to resolve the issue:

  1. Installed json-c using Homebrew: brew install json-c
  2. Specified the json-c directory in the configure command: --with-jsondir=/usr/local/Cellar/json-c/0.17/include/json-c
  3. Set the CFLAGS environment variable to include the json-c directory: export CFLAGS="-I/usr/local/Cellar/json-c/0.17/include/json-c/"
  4. Attempted to specify the PostgreSQL 16 pg_config directory in the configure command: --with-pgconfig=/usr/local/Cellar/postgresql@16/16.2_1/bin/pg_config

Despite these efforts, I'm still encountering the same error message. I suspect there may be additional dependencies missing or an issue with the environment configuration, particularly concerning PostgreSQL 16 compatibility.

Could someone provide guidance on how to troubleshoot and resolve this compilation issue for PostGIS on macOS, particularly with respect to integrating with PostgreSQL 16? Any insights, suggestions, or alternative approaches would be highly appreciated.

Thank you for your assistance!

P.S. Already tried steps from this StackOverflow response: on StackOverflow but I'm blocked at this step: ./configure --with-projdir=/opt/homebrew/opt/proj --with-protobufdir=/opt/homebrew/opt/protobuf-c --with-pgconfig=/opt/homebrew/opt/postgresql@16/bin/pg_config --with-jsondir=/opt/homebrew/opt/json-c --with-sfcgal=/opt/homebrew/opt/sfcgal/bin/sfcgal-config --with-pcredir=/opt/homebrew/opt/pcre "LDFLAGS=$LDFLAGS -L/opt/homebrew/Cellar/gettext/0.22.2/lib" "CFLAGS=-I/opt/homebrew/Cellar/gettext/0.22.2/include"

EDIT: Ultimately, it couldn't work. My Pgsql kept pointing to v14 instead of v16 due to the forced installation of pgsql@14 when downloading postgis in the first place. Perhaps because I am using an M1 Mac. Had to use the following method which I recommend for M1 Mac users: LEARN how to setup POSTGRESQL / POSTGIS and PgAdmin4 on DOCKER

0

There are 0 best solutions below