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

MacOSX High Sierra下PostGIS ST_AsMVT()报错缺失libprotobuf-c

解决PostGIS ST_AsMVT()报“缺失libprotobuf-c”错误的方案

我之前在MacOS High Sierra 10.13.1上用PostGIS 2.4.0生成MVT时也碰到过一模一样的问题,折腾了好一阵才搞定,给你几个亲测有效的步骤:

  • 先确认libprotobuf-c是否已安装
    打开终端,执行命令:

    brew list | grep protobuf-c
    

    如果没有任何输出,说明这个依赖库还没装,直接用Homebrew安装:

    brew install protobuf-c
    

    要是你用的是MacPorts,替换成:

    port install protobuf-c
    
  • 重新安装PostGIS,确保它关联上libprotobuf-c
    很多时候这个错误是因为你先装了PostGIS,之后才补装的libprotobuf-c,导致PostGIS编译时没链接到这个库。解决办法是重新安装PostGIS:

    1. 先卸载现有PostGIS:
      brew uninstall postgis
      
      (MacPorts用户用port uninstall postgis)
    2. 确保libprotobuf-c已经装好后,重新安装PostGIS:
      brew install postgis
      
      要是你是源码编译安装的PostGIS,记得在configure阶段指定protobuf-c的路径,比如:
      ./configure --with-protobuf-c=/usr/local/opt/protobuf-c
      make && make install
      
  • 验证依赖是否正确链接
    可以检查PostGIS的库文件是否关联了libprotobuf-c,执行命令:

    otool -L /usr/local/lib/postgresql/postgis-2.4.so
    

    查看输出里有没有类似libprotobuf-c.1.dylib的条目,如果有就说明链接成功了。

  • 重启PostgreSQL服务
    最后一定要重启PostgreSQL,让新的库加载生效:

    brew services restart postgresql
    

    之后再尝试执行你的ST_AsMVT()查询,应该就能正常生成MVT数据了。

内容的提问来源于stack exchange,提问作者Edgar P.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 03:59:34