php7.1 编译错误

错误:

Undefined symbols for architecture x86_64:
"_append_history", referenced from:
_readline_shell_run in readline_cli.o
"_history_list", referenced from:
_zif_readline_list_history in readline.o
"_libiconv", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_appendl in iconv.o

"_libiconv_close", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o

"_libiconv_open", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o

"_rl_mark", referenced from:
_zif_readline_info in readline.o
"_rl_pending_input", referenced from:
_zif_readline_info in readline.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: *** [sapi/cli/php] Error 1

解决思路:

readline_cli.o iconv.o 外部lib找不到,手动替换makefile中的

解决方法:

修改 configure 后生成的 Makefile 文件,找到 EXTRA_LIBS 变量

删除:
-liconv

增加:
/usr/local/Cellar/libiconv/1.15/lib/libiconv.dylib /usr/local/Cellar/readline/7.0.5/lib/libhistory.dylib /usr/local/Cellar/readline/7.0.5/lib/libreadline.7.0.dylib

修改后:

EXTRA_LIBS = -lcrypto -lssl -lcrypto -lz -lresolv -lreadline -lncurses -lmcrypt -lltdl  /usr/local/Cellar/libiconv/1.15/lib/libiconv.dylib /usr/local/Cellar/readline/7.0.5/lib/libhistory.dylib /usr/local/Cellar/readline/7.0.5/lib/libreadline.7.0.dylib -lintl -lpng -lz -ljpeg -lcurl -lbz2 -lz -lcrypto -lssl -lcrypto -lm -lxml2 -lz -licucore -lm -lcurl -lldap -lz -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm

参考:

https://dream128.cn/index.php?m=Article&a=detail&id=65


发表评论

电子邮件地址不会被公开。 必填项已用*标注