You can install the XML::LibXML module using standard tools like cpanm, but there
are a couple of factors to consider first. Because the module wraps a C
library, to install this way you must have a C compiler installed and you must
have already installed the
libxml2 library along with its development
Since version 2.0200, the XML::LibXML distribution uses a dependency on
Alien::Libxml2 to install the
libxml2 library if your system does not
already have it. So if the easier install options listed below are not
suitable for your use case, you may be able to just use the normal CPAN
cpan install XML::LibXML
There may be easier install options for your platform.
Installing on Windows¶
The most popular Perl distribution for Windows is Strawberry Perl, which happens to include XML::LibXML in the base Perl installer. So if you have Strawberry Perl, you already have XML::LibXML.
Another popular Perl distribution for Windows is ActivePerl from ActiveState (who also package Perl for Mac OS X, Linux and Solaris). ActivePerl includes a tool called PPM (Perl Package Manager) for installing pre-built Perl modules. You can use the PPM graphical user interface to search for the XML::LibXML package then click to select and install it. A command-line interface is also available:
ppm install XML-LibXML
Installing on Linux¶
If you are using the system Perl binary, you can install a pre-compiled version of XML::LibXML and the underlying libxml2 library from your distribution’s package archive.
On systems using dpkg/apt (Debian, Ubuntu, Mint, etc.):
sudo apt-get install libxml-libxml-perl
On systems using rpm/yum (RedHat, CentOS, Fedora, etc.):
sudo yum install "perl(XML::LibXML)"
If for some reason you want to compile and install a version of XML::LibXML
directly from CPAN, you must first install both the
libxml2 library and
the header files for linking against the library. The easiest way to do this
is to use your distribution’s packages. For example on Debian:
sudo apt-get install libxml2 libxml2-dev
You can test that the library is correctly installed and your PATH is set up correctly with this command:
For more information about manual builds, refer to the README file in the XML::LibXML distribution.
Installing on Mac OS X¶
You can install the
libxml2 library using homebrew:
brew install libxml2
If you do not have Homebrew, you can install it at the homebrew website.
Once you have the
libxml2 library installed, you can install the
XML::LibXML Perl module using standard tools such as