迹忆客 专注技术分享

当前位置:主页 > 学无止境 > 编程语言 >

mac 系统下 编译 php7.1 报错及解决方式

作者:迹忆客 时间:2021/05/28 浏览次数:

在使用 configure 配置过程中报的错误。

$ ./configure --prefix=/usr/local/php7/ --enable-debug --enable-maintainer-zts --enable-mysqlnd --with-mysqli --with-openssl --enable-pcntl --enable-mbstring --with-curl --enable-fpm

问题一、 openssl问题

和openssl有关(当然,系统中已经安装了openssl)。报如下的错误:

checking for ..../pkg-config
error: Cannot find OpenSSL's <evp.h>

解决方法,

For compilers to find libressl you may need to set:
  export LDFLAGS="-L/usr/local/opt/libressl/lib"
  export CPPFLAGS="-I/usr/local/opt/libressl/include"

For pkg-config to find libressl you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libressl/lib/pkgconfig"

问题二、 iconv问题

问题一解决之后,新的问题又来了。

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

解决方法

$ brew install libiconv

先安装libiconv,然后在configure中指定--with-iconv 选项。如下

$ ./configure --prefix=/usr/local/php7/ --enable-debug --enable-maintainer-zts --enable-mysqlnd --with-mysqli --with-openssl --enable-pcntl --enable-mbstring --with-curl --enable-fpm --with-iconv=$(brew --prefix libiconv)
make 过程报错
SHLIB_DL_SUFFIX_NAME = so
"Makefile" 1713L, 277679C
      _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)

解决办法: 编辑 Makefile 找到 EXTRA_LIBS = 。。。 将 -liconv 替换成 /usr/local/Cellar/libiconv/1.16/lib/libiconv.dylib
可以根据自己系统的实际路径替换

除非注明转载,本站文章均为原创,欢迎转载,转载请以链接形式注明出处

本文地址:

迹忆客

专注技术分享,项目实战分享!

技术宅 乐于分享 7年编程经验
社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

热门文章

热门标签