Compiling PHP Intl extension on Mac Book Pro (El Capitan 10.11.4)

时间:2016-04-04 16:45:24

标签: php macos pear pecl

I am trying to install the PHP Intl extension on my new Mac (El Capitan 10.11.4) using PECL, but there is a linking error during the make stage.

Here are the steps I took:

  1. Installed PEAR to run on Mac

  2. Compiled and installed the ICU library (version 51.2) into /usr/local/lib

  3. Ran this command: sudo pecl install intl and there was an error (see below). I also tried compiling the extension directly from the PHP source code ("ext" folder) and received the same error message.

I am getting the following error:

ld: file not found: libicudata.51.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [intl.la] Error 1
ERROR: 'make' failed

It looks like:

  1. The file is missing (even though it knows the correct ICU library version to look for). Maybe it truly can't find the file. The -L switch and related switches appear to point to the correct path /usr/local/lib path.

  2. Then, there is also some sort of architecture mismatch. So, I ran file libicudata.51.dylib and it appears to be the right architecture.

Here is what file retuned:

$ file /usr/local/lib/libicudata.51.dylib
/usr/local/lib/libicudata.51.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Has anyone run across this before? Or know how to compile PHP's Intl extension on the new Mac Book Pro (El Capitan 10.11.4)? I a hoping for some hints on where to look next, because I am a bit stumped here.

4 个答案:

答案 0 :(得分:5)

也许你可以试试这个:

brew install php56-intl

答案 1 :(得分:2)

您可以考虑查看这些主题(https://github.com/Homebrew/homebrew-php/issues/1701)和(https://github.com/Homebrew/homebrew-php/issues/1710)。我试图重现你的错误,但我失败了。最可能的原因是没有链接的icu4c。

尝试使用brew link --force icu4c

我尝试使用php70和

sudo pecl install intl

失败。我尝试使用php56,一切顺利。

尝试运行php -v master,此类内容应显示

C02QH2D7G8WM:workspace userone$ php -v master
PHP 5.6.20 (cli) (built: Apr  1 2016 08:53:48) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

答案 2 :(得分:1)

尝试运行:

brew install homebrew/php/php56-intl

答案 3 :(得分:0)

我解决了这个问题,这是我的环境:

  操作系统:El Capitan 10.11.4
  PHP:php-7.0.5
  icu:​​55.1

关键点是使用--enable-rpath重新安装ICU:

./configure --prefix=/opt/oss/icu --enable-release --enable-shared --enable-rpath --enable-tools

如果您想知道原因,请以root身份运行

otool -L $YOUR_ICU_PREFIX/lib/libicudata.dylib

检查第一个库是否是绝对路径。