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

4

8

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.

Trin answered 4/4, 2016 at 16:45 Comment(12)
What happens when you try to compile a C stub program (int main(){return 0;}) with cc -licudata -o test test.c?Substantialize
I tried as you suggested, and the stub test.c program compiles without any error messages.Trin
Do you need to use PECL? You may want to consider using homebrew as it works very efficiently. brew.shBryner
Well, good question. I got a new Mac, and after reading about the SIP constraints, I was thinking it might be best to simply install the applications and libraries individually. It might also be good if I want to learn more about the various switches and options, at least for the software I use more frequently. To your point, I could see that being overkill, too; the bad old days for the average user.Trin
Where would I look to see any notes in how the package in Homebrew was prepared? Someone must have ran into similar types of errors, when preparing packages for Homebrew. So, is there a place to look that up?Trin
I couldn't reproduce this error, what php version are you using.Secrecy
See this github.com/Homebrew/homebrew-php/issues/1710. I use brew too and maybe "brew update && brew reinstall php56 && brew reintsasll icu4c" would workSecrecy
The Mac Book Pro laptop came installed with php v5.5.31.Trin
What is your icu4c version?Secrecy
The icu4c version I downloaded was 51.2 because of the PECL binary dependency, but now I am reading it again, I think I should be looking at the PHP docs to find out what version to use. I tried 51.2, 52.1, and the latest 57.1, which all seemed to yield the same error.Trin
Let us continue this discussion in chat.Trin
Isn't intl included with PHP for a long time now? Have you set DYLD_LIBRARY_PATH before running pecl?Moke
I
0

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.

Interline answered 23/4, 2016 at 6:36 Comment(1)
I just went with using brew, so I won't be able to check, but thank you for your help!Trin
F
5

Maybe you can try just this:

brew install php56-intl
Forta answered 3/9, 2016 at 9:49 Comment(0)
S
2

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
Secrecy answered 7/4, 2016 at 2:24 Comment(6)
I am using php 5.5, it was built Feb 20, 2016Trin
I can try building php 5.6, and see if building that extension works.Trin
@BiagioArobba you can brew install php56 and brew unlink php55Secrecy
Wait right you compiled it, right go ahead and compile php56Secrecy
Ok, I tried upgrading things. So, I compiled the latest ICU 57.1 and PHP 5.6.20, and got the same error message ld: file not found: ... for architecture x86_64Trin
Just a note. I am trying to stay away from using Homebrew.Trin
D
1

Try run:

brew install homebrew/php/php56-intl
Donettedoney answered 3/1, 2017 at 18:58 Comment(0)
I
0

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.

Interline answered 23/4, 2016 at 6:36 Comment(1)
I just went with using brew, so I won't be able to check, but thank you for your help!Trin

© 2022 - 2024 — McMap. All rights reserved.