为PostgreSQL v11安装Apache AGE时链接命令执行失败
PostgreSQL 11 安装 Apache AGE 时
make install 报错:_pg_snprintf 符号未定义 问题详情
尝试为PostgreSQL v11安装Apache AGE,执行make install时出现链接错误,核心报错信息如下:
Undefined symbols for architecture x86_64: "_pg_snprintf", referenced from: _get_next_default_alias in cypher_parse_node.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [age.so] Error 1
环境信息:
- PostgreSQL从
REL_11_STABLE分支编译安装,配置参数:
./configure --prefix=/usr/local/pgsql --enable-cassert --enable-debug CFLAGS="-glldb -ggdb -O0 -g3 -fno-omit-frame-pointer"
- 尝试过从AGE的
master和PG11分支编译安装
解决方案
1. 确保AGE分支与PostgreSQL版本严格匹配
PostgreSQL 11必须对应AGE的PG11分支,master分支适配的是最新版PostgreSQL,请勿混用。重新切换到正确分支:
cd age git checkout PG11
2. 显式链接PostgreSQL的libpgcommon库
_pg_snprintf是PostgreSQL内部函数,属于libpgcommon库,AGE的PG11分支链接配置中可能遗漏了该库。执行编译时添加链接参数:
make clean make LIBS="-lpgcommon" install
3. 重新完整编译(可选)
如果之前的编译缓存残留问题,可清理后重新配置编译:
make clean ./configure --prefix=/usr/local/pgsql --enable-cassert --enable-debug CFLAGS="-glldb -ggdb -O0 -g3 -fno-omit-frame-pointer" make LIBS="-lpgcommon" install
原因说明
_pg_snprintf是PostgreSQL提供的安全格式化函数,在PostgreSQL 11中封装于libpgcommon库内。AGE的编译脚本默认可能未包含该库的链接指令,导致链接阶段无法找到符号,显式添加-lpgcommon即可解决该问题。
内容的提问来源于stack exchange,提问作者Ken W.
相关产品推荐
相关产品推荐

