Linux, Perl

Installing XML::Parser fails and requires expat.h

Sending
User Rating 5 (1 vote)

perl cpan installationI had to install XML::Parser CPAN module to parse some of the xml files. But I was getting “requires expat.h” error while installing it. In short, XML::Parser is the module for parsing XML documents.

I am using Ubuntu 14.10 and below is the snippet of error that I got.


chmod 644 Expat.bs
/usr/bin/perl /usr/share/perl/5.20.2/ExtUtils/xsubpp -noprototypes -typemap /usr/share/perl/5.20/ExtUtils/typemap -typemap typemap  Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
cc -c   -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"2.44\" -DXS_VERSION=\"2.44\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.20/CORE"   Expat.c
Expat.xs:12:19: fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
Makefile:317: recipe for target 'Expat.o' failed
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory '/home/sanjeev/.cpan/build/XML-Parser-2.44-8nA0zK/Expat'
Makefile:592: recipe for target 'subdirs' failed
make: *** [subdirs] Error 2
TODDR/XML-Parser-2.44.tar.gz
/usr/bin/make -- NOT OK

Install expat manually

  1. Install expat by downloading it from http://sourceforge.net/projects/expat/
  2. Extract tar file i.e. tar -xvzf expat-2.1.0.tar.gz
  3. cd expat-2.1.0
  4. run executable ‘configure’ file in terminal i.e.
    ./configure
  5. run make command in terminal i.e.
    make
  6. then
    make install

Now install XML::Parser from CPAN

You can use any CPAN installation methods. I prefer using cpanm command i.e.

sudo cpanm XML::Parser

sudo cpanm XML::Parser
--> Working on XML::Parser
Fetching http://www.cpan.org/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz ... OK
Configuring XML-Parser-2.44 ... OK
Building and testing XML-Parser-2.44 ... OK
Successfully installed XML-Parser-2.44
1 distribution installed

Let me know if solves expat.h related issue for you also. Comment if you face any issues for installing XML::Parser.

 

Share your Thoughts