I am working on getting Monarch installed on a server to manage Nagios file. Part of the setup includes installing a bunch of items using Perl’s CPAN. One of the packages I needed to install was called “XML::LibXML::Common” but it failed with an error. The error was overcome on CentOS by installing libxml2-devel using yum. Below are details regarding the error, the yum command to resolve the issue, and the end of a successful install of the initial package.
Perl CPAN Error Building XML::LibXML::Common -> libxml2 not found
When attempting to install XML::LibXML::Common using the CPAN shell I received the below error messages.
- running xml2-config...
- using fallback values for LIBS and INC
- options:
- LIBS='-L/usr/local/lib -L/usr/lib -lxml2 -lm'
- INC='-I/usr/local/include -I/usr/include'
- If this is wrong, Re-run as:
- $ /usr/bin/perl Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'
- looking for -lxml2... no
- looking for -llibxml2... no
- libxml2 not found
- Try setting LIBS and INC values on the command line
- Or get libxml2 from
- http://xmlsoft.org/
- If you install via RPMs, make sure you also install the -devel
- RPMs, as this is where the headers (.h files) are.
- Also, you may try to run perl Makefile.PL with the DEBUG=1 parameter
- to see the exact reason why the detection of libxml2 installation
- failed or why Makefile.PL was not able to compile a test program.
- make: *** No targets specified and no makefile found. Stop.
- /usr/bin/make -- NOT OK
- Running make test
- Can't test without successful make
- Running make install
- make had returned bad status, install seems impossible
- cpan>
As you can see from the above CPAN output the error is with libxml2. I checked using yum (yum list *LIBXML2*) and the server did have the libxml2.i386 package installed. Sometimes the development packages are also needed so I noticed that a package titled libxl2-devel was also available. I went ahead and installed that using yum as displayed in the below example.
Install libxml2-devel Using Yum On CentOS Linux:
- [root@server ~]# yum install libxml2-devel
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * addons: mirrors.tummy.com
- * base: mirrors.tummy.com
- * centosplus: mirror.raystedman.net
- * epel: mirrors.tummy.com
- * extras: mirror.raystedman.net
- * rpmforge: apt.sw.be
- * updates: mirror.skiplink.com
- Setting up Install Process
- Resolving Dependencies
- --> Running transaction check
- ---> Package libxml2-devel.i386 0:2.6.26-2.1.2.8 set to be updated
- --> Processing Dependency: zlib-devel for package: libxml2-devel
- --> Running transaction check
- ---> Package zlib-devel.i386 0:1.2.3-3 set to be updated
- --> Finished Dependency Resolution
- Dependencies Resolved
- ====================================================================================================================================
- Package Arch Version Repository Size
- ====================================================================================================================================
- Installing:
- libxml2-devel i386 2.6.26-2.1.2.8 base 2.1 M
- Installing for dependencies:
- zlib-devel i386 1.2.3-3 base 101 k
- Transaction Summary
- ====================================================================================================================================
- Install 2 Package(s)
- Update 0 Package(s)
- Remove 0 Package(s)
- Total download size: 2.2 M
- Is this ok [y/N]: y
- Downloading Packages:
- (1/2): zlib-devel-1.2.3-3.i386.rpm | 101 kB 00:00
- (2/2): libxml2-devel-2.6.26-2.1.2.8.i386.rpm | 2.1 MB 00:01
- ------------------------------------------------------------------------------------------------------------------------------------
- Total 1.0 MB/s | 2.2 MB 00:02
- Running rpm_check_debug
- Running Transaction Test
- Finished Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : zlib-devel 1/2
- Installing : libxml2-devel 2/2
- Installed:
- libxml2-devel.i386 0:2.6.26-2.1.2.8
- Dependency Installed:
- zlib-devel.i386 0:1.2.3-3
- Complete!
As you can see above the zlib-devel package was also installed as a dependency of libxml2-devel. If you are on a different distribution other than CentOS the package manager available for your Linux distro will more than likely include libxml2-devel. After installing libxml2-devel I restarted the CPAN shell and I was able to install XML::LibXML::Common without issue.
Thanks for this! I just ran into the same issue and that solved it.
Hello Ken,
No problem. Thanks for taking the time to leave feedback.
Thanks.
alex