The pre-configuration script for libxml2 does a pretty good job, but it doesn’t quite catch one missing dependency on RHEL 5
Chances are you’ll never need to build libxml2, the fairly ubiquitous XML library provided by www.xmlsoft.org, on your Linux box. It’s more than likely already on your system since so many of the packages you use depend on it. If by chance it isn’t on your system, your distro will almost certainly have a precompiled version to match.
But if you need to build later versions of some packages on your server you might find that your pre-packaged libxml2 isn’t quite up to the job, such as when building the latest Apache modsecurity on Red Hat Enterprise Linux 5:-
… checking for libxml2 config script... /usr/bin/xml2-config checking if libxml2 is at least v2.6.29... no, 2.6.26 configure: error: NOTE: libxml2 library must be at least 2.6.29
Getting up-to-date
The Downloads page on xmlsoft.org provides links to the latest pre-built versions for many systems, however given both its dependencies and the other applications on your system that may depend on it you might find building from source and installing into a separate directory worthwhile.
Pull down the latest tarball (currently libxml2-2.9.1.tar.gz) from the FTP server link on the downloads page and extract to a local directory.
It’s the usual configure -> make -> make install process to perform your build, but to segregate this version from the default on your system you might want to use the –prefix option to set the target directory:-
# ./configure --prefix=/home/builds/libxml2-2.9.1 # make # make install
The configure script does a pretty good job at spotting any missing dependencies, though on my RHEL system my make fell over with several thousand lines of errors when it came to building Python support:-
… libxml.c:3821: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'libxmlMethods' libxml.c:3876: warning: ISO C does not allow extra ';' outside of a function libxml.c: In function 'initlibxml2mod': libxml.c:3908: error: 'PyObject' undeclared (first use in this function) libxml.c:3908: error: 'module' undeclared (first use in this function) libxml.c:3914: warning: implicit declaration of function 'Py_InitModule' libxml.c:3914: warning: nested extern declaration of 'Py_InitModule' libxml.c:3914: error: 'libxmlMethods' undeclared (first use in this function) make[4]: *** [libxml.lo] Error 1 make[4]: Leaving directory `/home/builds/libxml2-2.9.1/python'
Getting to the root cause of this one taxed the scrollback on my terminal window more than somewhat but at the top of the errors there it was:-
libxml.c:14:20: error: Python.h: No such file or directory libxml.c:15:24: error: fileobject.h: No such file or directory
My system was missing any Python headers though it contained a Python runtime which happens to be all the configure script is checking for:-
… configure:14042: checking for python configure:14060: found /usr/bin/python configure:14072: result: /usr/bin/python …
There are three ways to get round this. If you don’t actually need the Python support in your libxml2 build, disable it on your configure command:-
# ./configure --prefix=/home/builds/libxml2-2.9.1 --with-python=no # make clean # make # make install
If you have a Python 2 built from source on your system you could point your libxml2 build at that one instead (which you’d probably want to do if that’s the Python version you want to use with it):-
# ./configure --prefix=/home/builds/libxml2-2.9.1 --with-python=/home/builds/python-2.4 # make # make install
Thirdly you could install the python-devel package to match the Python runtime in your Linux distro. yum list | grep python-devel will turn up the package you need, on RHEL 5.6 the following RPM adds what’s needed:-
# rpm --install python-devel-2.4.3-43.el5.i386.rpm # make # make install
It helps me a lot! Thanks!
Thanks. Superb , resolved my issue.
Thanks, resolved my issuse.