书中使用的是7.0版本,由于php.net上下载太慢,于是使用本地现有的7.2版本的代码.

./configure --prefix=/Users/luzhifang/php/php-7.3.4/output/ --enable-fpm

过程中出现错误

configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

这是因为iconv模块是php的默认安装模块,此处如果不需要iconv的话可以使用--without-iconv.
如果想把iconv模块也编译在内的话,可以按如下方式解决,先查找到本机安装libiconv的目录,如果没有安装就只能先自己安装,本机上libiconv的目录是

/usr/local/opt/libiconv

所以重新执行configure命令

./configure --prefix=/Volumes/Samsung_T5/useful-zips/php7 --enable-debug --enable-fpm --with-iconv=/usr/local/opt/libiconv/

ok,configure成功.
然后执行make

make

又报错

 -lz -licucore -lm  -o sapi/cli/php
Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_encode in iconv.o
      __php_iconv_appendl in iconv.o
      _php_iconv_stream_filter_append_bucket in iconv.o
      ...
  "_libiconv_close", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_encode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      ...
  "_libiconv_open", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_encode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _php_iconv_stream_filter_ctor in iconv.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

解决方案

在Makefile文件中搜索liconv,将,将EXTRA_LIBS = 这一行内的 -liconv 替换成 /usr/local/opt/libiconv/lib/libiconv.dylib

再次

make && make install

编译顺利完成.
PS,MacOS上安装gdb调试工具出错可以参考

https://stackoverflow.com/questions/52529838/gdb-8-2-cant-recognized-executable-file-on-macos-mojave-10-14
https://blog.csdn.net/weixin_41978191/article/details/89431694

马尔科夫尼可夫
19 声望5 粉丝

酷白发,小酒窝,主角标配的帅小伙~