Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 : http://serverfault.com/questions/133785/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 \
--with-icu-dir=/opt/local


i change Makefile, replace this:

$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so

to this :

$(CC) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(MH_BUNDLE_FLAGS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so

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

share|improve this question

4 Answers 4

up vote 0 down vote accepted

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.

share|improve this answer
    
yes, for the moment i think it"s the best solution, i do the same. –  jules Sep 3 '10 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

share|improve this answer

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.

share|improve this answer

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:

#ifdef LIBXML_ICU_ENABLED 
/* 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;
#endif
#endif

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.