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:- 先卸载现有PostGIS:
(MacPorts用户用brew uninstall postgisport uninstall postgis) - 确保libprotobuf-c已经装好后,重新安装PostGIS:
要是你是源码编译安装的PostGIS,记得在configure阶段指定protobuf-c的路径,比如:brew install postgis./configure --with-protobuf-c=/usr/local/opt/protobuf-c make && make install
- 先卸载现有PostGIS:
验证依赖是否正确链接
可以检查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.
相关产品推荐
相关产品推荐

