简体   繁体   中英

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

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.

也许你可以试试这个:

brew install php56-intl

You might consider looking at these threads ( https://github.com/Homebrew/homebrew-php/issues/1701 ) and ( https://github.com/Homebrew/homebrew-php/issues/1710 ). I tried to reproduce your error but I failed. The most probable reason would be an icu4c that is not linked.

Try using brew link --force icu4c

I tried using php70 and

sudo pecl install intl

failed. I tried using php56, everything ran smoothly.

Try running php -v master , something like this should show up

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

试试运行:

brew install homebrew/php/php56-intl

I fixed this problem,here is my environment:

OS : El Capitan 10.11.4
PHP : php-7.0.5
icu : 55.1

the key point is reinstall ICU using --enable-rpath :

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

If you want to know why,please run as root

otool -L $YOUR_ICU_PREFIX/lib/libicudata.dylib

to check if the first library is absolute path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM