How to Install libxml2 2.7.X on CentOS 5.X with Dependency Resolution for GLIBC_2.7


2 views

When attempting to upgrade libxml2 on CentOS 5.X systems, you'll encounter a fundamental compatibility issue with GLIBC. The key error message reveals:

Missing Dependency: libc.so.6(GLIBC_2.7)(64bit) is needed by package libxml2-2.7.8-1.x86_64

CentOS 5.X ships with glibc-2.5, while libxml2 2.7.X requires glibc-2.7 symbols. This creates a critical system library version mismatch that prevents direct RPM installation.

Method 1: Source Compilation with Custom Prefix

The safest approach is compiling from source while maintaining system stability:

wget http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz
tar xzf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2-2.7.8 \
            --without-python \
            --disable-static
make
sudo make install

Add to your environment:

export PATH=/usr/local/libxml2-2.7.8/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/libxml2-2.7.8/lib:$LD_LIBRARY_PATH

Method 2: Using Software Collections (SCL)

For CentOS 5, you can leverage the CentOS SCL repository:

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install -y devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

Then compile with:

scl enable devtoolset-2 "bash"
cd libxml2-2.7.8
./configure --prefix=/opt/libxml2-2.7.8
make
sudo make install

If you need Python support, first install Python 2.6:

yum install -y python26 python26-devel

Then compile libxml2 with Python support:

./configure --prefix=/usr/local/libxml2-2.7.8 \
            --with-python=/usr/bin/python2.6 \
            --with-python-install-dir=/usr/lib/python2.6/site-packages

After installation, verify with:

/usr/local/libxml2-2.7.8/bin/xml2-config --version
python -c "import libxml2; print libxml2.__version__"
  • Never upgrade system glibc on CentOS 5 - it will break your OS
  • Consider containerization (Docker) for modern applications needing newer libraries
  • For production systems, evaluate upgrading to a newer CentOS/RHEL version

When attempting to upgrade libxml2 from the default 2.6.26 to version 2.7.8 on CentOS 5.X, you'll encounter GLIBC dependency conflicts. The key error message reveals:

Missing Dependency: libc.so.6(GLIBC_2.7)(64bit) is needed by package libxml2-2.7.8-1.x86_64

CentOS 5.X ships with glibc-2.5, while libxml2 2.7.X requires glibc-2.7+ symbols. Upgrading glibc on a production system is risky as it's a core library that nearly all applications depend on.

Instead of risking system stability with glibc upgrades, compiling from source with proper flags is more reliable:

wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
tar xvzf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2-2.7.8 --without-python
make
sudo make install

For Python applications needing the binding:

yum install python26 python26-devel
./configure --prefix=/usr/local/libxml2-2.7.8 --with-python=/usr/bin/python2.6

After installation, update your environment variables:

export PATH=/usr/local/libxml2-2.7.8/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/libxml2-2.7.8/lib:$LD_LIBRARY_PATH

Confirm successful installation with:

xml2-config --version
ldd /usr/local/libxml2-2.7.8/bin/xmllint | grep libc

For those preferring RPM packages, consider creating custom RPMs that don't enforce GLIBC 2.7 requirements:

rpmbuild --rebuild --define '_prefix /opt/libxml2-2.7.8' libxml2-2.7.8.src.rpm
  • The source-compiled version won't replace system libxml2
  • Applications must be configured to use the new library path
  • Consider using LD_PRELOAD for specific applications

For production systems, consider upgrading to CentOS 6+ where newer libxml2 versions are officially supported. The source installation method should only be temporary solution.