You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS编译PostGIS 3.4.0适配PostgreSQL 16遇json.h缺失问题求助

问题:macOS 12.7.3编译PostGIS 3.4.0(配合PostgreSQL 16)时缺失json.h头文件

编译过程中出现如下错误:

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

环境配置

  • 操作系统:macOS 12.7.3 Monterey
  • PostGIS版本:3.4.0
  • 依赖组件(均通过Homebrew安装):
    • proj:安装路径 /usr/local/opt/proj
    • protobuf-c:安装路径 /opt/homebrew/opt/protobuf-c
    • PostgreSQL 16:安装路径 /usr/local/Cellar/postgresql@16/16.2_1
    • json-c:安装路径 /usr/local/Cellar/json-c/0.17
    • sfcgal:安装路径 /usr/local/Cellar/sfcgal/1.5.1_1
    • pcre:安装路径 /opt/homebrew/opt/pcre

已尝试的解决步骤

  1. 通过Homebrew安装json-c:brew install json-c
  2. 在configure命令中指定json-c目录:--with-jsondir=/usr/local/Cellar/json-c/0.17/include/json-c
  3. 设置CFLAGS环境变量:export CFLAGS="-I/usr/local/Cellar/json-c/0.17/include/json-c/"
  4. 在configure命令中指定PostgreSQL 16的pg_config路径:--with-pgconfig=/usr/local/Cellar/postgresql@16/16.2_1/bin/pg_config

尽管尝试了以上方法,仍出现相同错误。怀疑可能缺少额外依赖,或环境配置存在问题,尤其是PostgreSQL 16的兼容性方面。希望能得到排查和解决该编译问题的指导,以及PostgreSQL 16集成的相关建议或替代方案。

补充说明

曾尝试过StackOverflow上的解决方案,但执行以下configure命令时受阻:

./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"

编辑:最终该方法未生效。由于使用的是M1 Mac,最初安装postgis时被强制安装了pgsql@14,导致系统始终指向PostgreSQL 14而非16。最终采用Docker配置PostgreSQL/PostGIS和PgAdmin4的方法解决,推荐给M1 Mac用户。


内容的提问来源于stack exchange,提问作者Oliver S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 18:25:28