Take the 2-minute tour ×

I'm trying to fix a bug in libxml2. I cannot get it to compile with --with-icu when using --prefix=/Server/software. I have submitted a bug report here, but I need to get it to compile for resolving a conflict when compiling PHP with intl support. I suspect it's a problem with the Makefile. My experience with Makefile's is limited. The desired result is coming up with a patch that can be submitted to the linked bug report.

The --with-icu flag causes LIBXML_ICU_ENABLED to be defined. The included code is supposed to resolve a conflict when including headers from both icu and libxml2 (specifically, both use UChar). The PHP plugin intl, activated with --enable-intl, requires icu. libxml2 is needed by PHP for DOM/XML functions.

There are two problems.

First, this config:

./configure --prefix=/Server/software --enable-shared --enable-static --with-icu

Results in:

configure: error: libicu config program icu-config not found

This happens because of this code in configure.in:

if test "$with_icu" != "yes" ; then
    echo Disabling ICU support
    if ${ICU_CONFIG} --cflags >/dev/null 2>&1
        ICU_LIBS=`icu-config --ldflags`
        echo Enabling ICU support
        AC_MSG_ERROR([libicu config program icu-config not found])

Specifically ICUCONFIG=icu-config isn't respecting --prefix=/Server/software. I can work around this by doing export PATH=/Server/software/bin:$PATH.

This "fixes" the ./configure problem.

Second, when I run make I get errors, the most relavent being:

./include/libxml/encoding.h:31:26: error: unicode/ucnv.h: No such file or directory

The unicode/uncv.h file is in /Server/software/include/unicode/uncv.h. I suspect the compiler is looking for this file in the local directory and in my /usr directory.

This is what the error is referring to:

#include <unicode/ucnv.h>

Clearly this is a path issue when using --with-icu and --prefix=/Server/software. Without --with-icu it compiles fine, but this is needed to resolve a define UChar conflict when compiling PHP with both icu and libxml2.

The result of icu-config --cflags is:

-O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long

This is being piped into /dev/null.

The result of icu-config --ldflags is:

-lpthread -lm -L/Server/software/lib -licui18n -licuuc -licudata -lpthread -lm

What needs to be changed to resolve these issues?

share|improve this question
I've posted a patch for the ICU_CONFIG problem: bugzilla.gnome.org/show_bug.cgi?id=663214 –  Arto Bendiken Nov 2 at 19:27

1 Answer 1

up vote 1 down vote accepted

So, take a look at where it's using icu-config. It should be doing something like icu-config --cppflags which should set -I/Server/Software/include or similar. You could work around it by setting CPPFLAGS to include such a parameter yourself.

Can you include the actual compile command line immediately before the error?

Sounds like a bug in libxml - it ought to search ${PREFIX}/bin for icu-config.

Also, ICU now exports pkg-config files, which are more of a standard way to find such items.

Try this before WITH_ICU :

    ICU_CPPFLAGS=`icu-config --cppflags`

update I'm going to quote Luke's last response. Glad it's working.

I solved the linker problems, so now it all works. For this question using libxml 2.7.7 was the solution. It seems OX X 10.6 ships with 2.7.8. So for it to work you have to compile libxml2 yourself with 2.7.7. The linker problems are solved by adding LIBS="-lresolv -lstdc++" just before PHP's ./configure. If installing to a non-standard location you also need to compile ICU with --enable-rpath. I've accepted your answer. Feel free to update it with this information :). – Luke 17 hours ago

share|improve this answer
I updated the question to include the more relavent parts of configure.in and the output of icu-config when used in configure.in. It appears icu-config --ldflags is supposed to pass /Server/software to make the include work in encoding.h, but it's not getting through. Trying to find other packages that may do something similar. –  Luke Nov 2 '11 at 22:27
Well that seems to have fixed the problem with building libxml2. But now my PHP's config fails with checking whether libxml build works... no. The relavant bit in config.log being configure:21707: gcc -o conftest -fvisibility=hidden -no-cpp-precomp -Wl,-rpath,/Server/software/lib -L/Server/software/lib conftest.c. Without compiling libxml2 with --with-icu PHP is fine (if I don't include --enable-intl, which I need). –  Luke Nov 3 '11 at 18:20
@Luke what does config.log in php say? Intl uses ICU as I assume you are aware. intl is using the same ICU you are using for libxml2, right? –  Steven R. Loomis Nov 3 '11 at 19:21
Yes, same ICU. Here is config.log pastebin.com/qKezu2Z3 and here are the commands i'm using pastebin.com/dYQwUCm0 along with the patch file pastebin.com/ss0L6ZLw . Make sure the patch file and script are both in /Server if you run it. –  Luke Nov 3 '11 at 22:02
@Luke line 092. and following look OK- the blank line is a bit strange - but it doesn't show the actual error. If you run 'gcc -o conftest .. ' yourself with the specified contents of conftest.c does it work? Need to find the actual error here. –  Steven R. Loomis Nov 3 '11 at 23:34

Your Answer


