Compiling intl extension for MAMP

Posted on March 21, 2011

79


IMPORTANT NOTICE (updated June 2nd 2011)

A stackoverflow user named “Psychonetics” has left a comment that the compiled intl extension does not work properly. I have yet the time to verify it. If you have an intel-based mac, you can try Psychonetics’s solution, which is to install and use Zend Server CE instead. If you still prefer MAMP, he suggested to extract the intl.so from Zend Server CE, which should be found under the directory /usr/local/zend/lib/php_extensions after installation, and copy it to MAMP directory /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/.

If anyone has found a solution to compile intl extension for MAMP properly, kindly leave a comment here.

While trying out Symfony2 Standard Edition, the configuration check recommended to install and enable the intl extension, which does not come with the latest version of MAMP.

Below are the steps to compile the intl extension for MAMP on Leopard:

Updated on May 4th 2011 (thanks to Web Hosting):

Step 0 (SNOW LEOPARD ONLY): Instruct the compiler to compile in both 32 and 64 bit.


> MACOSX_DEPLOYMENT_TARGET=10.6

> CFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp”

> CCFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe”

> CXXFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe”

> LDFLAGS=”-arch i386 -arch x86_64 -bind_at_load”

> export MACOSX_DEPLOYMENT_TARGET CFLAGS CCFLAGS CXXFLAGS LDFLAGS

Step 1: Download, compile and install ICU source code from International Components for Unicode (I used the version 4.6.1). Extract the archive and run the following in terminal:


> cd ~/Downloads/icu/source

> ./runConfigureICU MacOSX

> make

> make install

Step 2: Download and extract php source code archive in Downloads folder. The current latest version 1.9.5 of MAMP comes with php version 5.3.5. The source code can be obtained from the PHP’s Unsupported Historical Releases page. In order to compile intl extension, php source code has to be configured to generate some necessary files. After that, intl extension can be “configure, make and make install”. The following are the list of commands to be run in the terminal:


> export PATH=/Applications/MAMP/bin/php5.3/bin/:$PATH

> cd /Applications/MAMP/bin/php5.3

> mkdir include

> mv ~/Downloads/php-5.3.5 include/php

> cd include/php

> ./configure

> cd ext/intl

> phpize

> ./configure

> make

> make install

Step 3: Edit php.ini (/Applications/MAMP/conf/php5.3/php.ini) to add the line extension=intl.so and restart apache.

NOTE: incorrect. See above for updated Step 0 for Snow Leopard.

To compile on Snow Leopard (yet to be tested personally), instruct the compiler to compile in 32 bit or both 32 and 64 bit, by running:

./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch i386 -arch x86_64 -bind_at_load”

About these ads
Tagged: , , ,
Posted in: Symfony2