#### Beyond Linux® From Scratch (systemd Edition) - Version 10.1

### Chapter 9. General Libraries

- Prev

  libxkbcommon-1.0.3

- Next

  libxslt-1.1.34

- Up
- Home

# libxml2-2.9.10

## Introduction to libxml2

The libxml2 package contains libraries and utilities used for parsing XML files.

This package is known to build and work properly using an LFS-10.1 platform.

### Package Information

- Download (HTTP): http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz

- Download (FTP): ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz

- Download MD5 sum: 10942a1dc23137a8aa07f0639cbfece5

- Download size: 5.4 MB

- Estimated disk space required: 87 MB (add 15 MB for tests)

- Estimated build time: 0.2 SBU (add 0.3 SBU for tests)

### Additional Downloads

- Required patch: http://www.linuxfromscratch.org/patches/blfs/10.1/libxml2-2.9.10-security_fixes-1.patch

- Optional Testsuite: http://www.w3.org/XML/Test/xmlts20130923.tar.gz - This enables make check to do complete testing.

### libxml2 Dependencies

#### Optional

Python-2.7.18

### Note

Some packages which utilize libxml2 (such as GNOME Doc Utils) need the Python3 module installed to function properly and some packages will not build properly if the Python3 module is not available.

The old Python2 module can be built after `libxml2.so` has been installed, see Python2 libxml2-2.9.10 module.

#### Optional

ICU-68.2 (see below) and Valgrind-3.16.1 (may be used in the tests)

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/libxml2

## Installation of libxml2

Apply a patch to fix various errors:

    patch -p1 -i ../libxml2-2.9.10-security_fixes-1.patch

First fix a problem generating the Python3 module with Python-3.9.0 and later:

    sed -i '/if Py/{s/Py/(Py/;s/)/))/}' python/{types.c,libxml.c}

If you are going to run the tests, disable one test that causes the Python tests to terminate early with an error:

    sed -i 's/test.test/#&/' python/tests/tstLastError.py

If, and only if, you are using ICU-68.2, fix a build breakage caused by that version by running the following command:

    sed -i 's/ TRUE/ true/' encoding.c

Install libxml2 by running the following commands:

    ./configure --prefix=/usr    \
                --disable-static \
                --with-history   \
                --with-python=/usr/bin/python3 &&
    make

If you downloaded the testsuite, issue the following command:

    tar xf ../xmlts20130923.tar.gz

To test the results, issue: make check > check.log. A summary of the results can be obtained with grep -E '^Total|expected' check.log. If Valgrind-3.16.1 is installed and you want to check memory leaks, replace check with check-valgrind.

### Note

The tests use http://localhost/ to test parsing of external entities. If the machine where you run the tests serves as a web site, the tests may hang, depending on the content of the file served. It is therefore recommended to shut down the server during the tests, as the `root` user:

    systemctl stop httpd.service

Now, as the `root` user:

    make install

## Command Explanations

`--disable-static`: This switch prevents installation of static versions of the libraries.

`--with-history`: This switch enables Readline support when running xmlcatalog or xmllint in shell mode.

`--with-python=/usr/bin/python3`: Allows building the libxml2 module with Python3 instead of Python2.

`--with-icu`: Add this switch if you have built ICU-68.2, for better unicode support.

`--with-threads`: Add this switch to enable multithread support.

## Contents

Installed Programs: xml2-config, xmlcatalog, and xmllint
Installed Libraries: libxml2.so and libxml2mod.so (Python3 module)
Installed Directories: /usr/include/libxml2, /usr/lib/cmake/libxml2, /usr/share/doc/libxml2-2.9.10, /usr/share/doc/libxml2-python-2.9.10, and /usr/share/gtk-doc/html/libxml2

### Short Descriptions

xml2-config | determines the compile and linker flags that should be used to compile and link programs that use `libxml2`
xmlcatalog | is used to monitor and manipulate XML and SGML catalogs
xmllint | parses XML files and outputs reports (based upon options) to detect errors in XML coding
`libxml2.so` | provides functions for programs to parse files that use the XML format
`libxml2mod.so` | is the interface for Python3 to use `libxml2.so`

Last updated on 2021-02-19 21:30:09 -0800

- Prev

  libxkbcommon-1.0.3

- Next

  libxslt-1.1.34

- Up
- Home