i'm trying to compile php on my mac.

i've followed this tutorial : http://www.malisphoto.com/tips/php-on-os-x.html
i've also check this post : Compile PHP 5.3.2 with intl extension on Snow Leopard 10.6.3

here's my configure options :

./configure \
--prefix=/usr \
--with-apxs2=/usr/sbin/apxs \
--with-ldap=/usr \
--with-kerberos=/usr \
--enable-cli \
--with-zlib-dir=/usr \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets \
--with-iodbc=/usr \
--with-curl=/usr \
--with-config-file-path=/etc \
--sysconfdir=/private/etc \
--with-mysql-sock=/tmp \
--with-mysql=/usr/local/mysql \
--with-openssl=/usr \
--with-xmlrpc \
--with-xsl=/usr \
--without-pear \
--with-libxml-dir=/usr \
--with-iconv=/usr/local \
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
--with-gd \
--with-jpeg-dir=/opt/local \
--with-png-dir=/opt/local \
--with-freetype-dir=/opt/local \
--with-mcrypt=/opt/local \
--enable-intl \

i change Makefile, replace this:


to this :


i also had this -lstdc++ into EXTRA_LIBS in Makefile.

here's the error message :

In file included from /opt/local/include/unicode/utypes.h:36,
                 from /usr/local/src/php-5.3.3/ext/intl/grapheme/grapheme.h:21,
                 from /usr/local/src/php-5.3.3/ext/intl/php_intl.h:26,
                 from main/internal_functions.c:47:
/opt/local/include/unicode/umachine.h:308: error: redefinition of typedef ‘UChar’
/usr/include/libxml2/libxml/encoding.h:41: error: previous declaration of ‘UChar’ was here
make: *** [main/internal_functions.lo] Error 1

i tried another build without intl (delete 2 last lines in ./configure) and it works.

Can someone explain me the error message, or indicate what may be wrong in ./configure options ? many thanks in advance

4 Answers 4


I tried to make the same thing and it failed due to a lot of errors of the same type. I tried to correct one by one and I got one more! I "downgraded" to php 5.2.14 and had no more problem.

  • yes, for the moment i think it"s the best solution, i do the same.
    – jules
    Sep 3, 2010 at 11:13

Or,othen again, you could build libxml2 from the newest stable source package yourself, which is what I did, since going back to 5.2 wasn't an option and I compile virtually all of php's dependencies (libicu, too) manually on my G4 dev box: 1) get libxml2's latest released source package from http://www.xmlsoft.org/downloads.html 2) compile libxml2: tar xf libxml2-sources-2.7.7.tar.gz cd libxml2-2.7.7 VER=2.7.7 ./configure --enable-shared --enable-static --prefix=/opt/libxml2-${VER} make && make install cd /opt; rm -rf libxml2; ln -s libxml2-${VER} libxml2 3) compile php with --with-libxml-dir=/opt/libxml2 (don't forget to rm config.cache just in case you don't clean up everything between your configure/build attempts.)

hope it helps, chris


I know this is old, but I ran into the same issue. Simply commenting out the line

typedef uint16_t UChar;

in /opt/local/include/unicode/umachine.h solved the issue for me.


The problem is that both ICU and libxml2 define the UChar. This is the problematic code in libxml2, specifically /usr/include/libxml2/libxml/encoding.h:

/* Forward-declare UConverter here rather than pulling in <unicode/ucnv.h>  
 * to prevent unwanted ICU symbols being exposed to users of libxml2.  
 * One particular case is Qt4 conflicting on UChar32: <rdar://problem/5100933>.  
#include <stdint.h> struct UConverter; typedef struct UConverter UConverter;
#ifdef _MSC_VER typedef wchar_t UChar;
#else typedef uint16_t UChar;

If you install libxml2 from source, this code seems not to be there, so I solved the problem by using libxml2 installed from source.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .