如何修补 libxml2,以便在使用前缀时可以使用 ICU 支持进行编译?
我正在尝试修复 libxml2 中的错误。使用 --prefix=/Server/software
时,我无法使用 --with-icu
进行编译。我已经提交了错误报告,但我需要对其进行编译解决编译带有 intl 支持的 PHP 时的冲突。我怀疑是Makefile的问题。我对 Makefile 的经验有限。期望的结果是提供一个可以提交到链接的错误报告的补丁。
--with-icu
标志导致定义LIBXML_ICU_ENABLED
。包含的代码应该可以解决包含 icu 和 libxml2 中的标头时的冲突(具体来说,两者都使用 UChar)。使用 --enable-intl
激活的 PHP 插件 intl 需要 icu。 PHP 需要 libxml2 来实现 DOM/XML 函数。
有两个问题。
首先,此配置:
./configure --prefix=/Server/software --enable-shared --enable-static --with-icu
结果:
configure: error: libicu config程序 icu-config 未找到
发生这种情况是因为 configure.in 中的以下代码:
WITH_ICU=0
if test "$with_icu" != "yes" ; then
echo Disabling ICU support
else
ICU_CONFIG=icu-config
if ${ICU_CONFIG} --cflags >/dev/null 2>&1
then
ICU_LIBS=`icu-config --ldflags`
LDFLAGS="$LDFLAGS $ICU_LIBS"
WITH_ICU=1
echo Enabling ICU support
else
AC_MSG_ERROR([libicu config program icu-config not found])
fi
fi
具体来说,ICUCONFIG=icu-config
不尊重 --prefix=/Server/software< /代码>。我可以通过执行
export PATH=/Server/software/bin:$PATH
来解决此问题。
这“修复”了 ./configure 问题。
其次,当我运行 make
时,出现错误,最相关的是:
./include/libxml/encoding.h:31:26: error: unicode/ucnv.h: No such file或者 目录
unicode/uncv.h
文件位于/Server/software/include/unicode/uncv.h
中。我怀疑编译器正在本地目录和我的 /usr 目录中查找此文件。
这就是错误所指的内容:
#ifdef LIBXML_ICU_ENABLED
#include <unicode/ucnv.h>
#endif
显然,这是使用 --with-icu
和 --prefix=/Server/software
时的路径问题。如果没有 --with-icu
,它可以正常编译,但是在使用 icu 和 libxml2 编译 PHP 时需要解决定义 UChar 冲突。
icu-config --cflags 的结果是:
-O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long< /code>
这正在通过管道传输到 /dev/null。
icu-config --ldflags
的结果是:
-lpthread -lm -L/Server/software/lib -licui18n -licuuc -licudata -lpthread -lm
需要做什么是否需要改变来解决这些问题?
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:
WITH_ICU=0
if test "$with_icu" != "yes" ; then
echo Disabling ICU support
else
ICU_CONFIG=icu-config
if ${ICU_CONFIG} --cflags >/dev/null 2>&1
then
ICU_LIBS=`icu-config --ldflags`
LDFLAGS="$LDFLAGS $ICU_LIBS"
WITH_ICU=1
echo Enabling ICU support
else
AC_MSG_ERROR([libicu config program icu-config not found])
fi
fi
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:
#ifdef LIBXML_ICU_ENABLED
#include <unicode/ucnv.h>
#endif
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,看看它在哪里使用了 icu-config。它应该执行诸如
icu-config --cppflags
之类的操作,应设置-I/Server/Software/include
或类似的操作。您可以通过设置 CPPFLAGS 自行包含此类参数来解决此问题。您可以在错误发生之前立即包含实际的编译命令行吗?
听起来像是 libxml 中的错误 - 它应该在 ${PREFIX}/bin 中搜索 icu-config。
此外,ICU 现在导出
pkg-config
文件,这更像是查找此类项目的标准方法。在
WITH_ICU
之前尝试一下:更新 我将引用 Luke 的最后回复。很高兴它起作用了。
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
:update I'm going to quote Luke's last response. Glad it's working.