error – expat.h: No such file or directory

While trying to get a perl utility working, I had to install a bunch of prerequisite perl modules on my CentOS 5 VPS. One requirement was XML::Parser. However when I tried to install it like so:

[root@localhost]perl -MCPAN -e shell
cpan> install XML::Parser

I received errors with the below being the most relevent bit…

cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -noprototypes -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -DVERSION=\”2.36\” -DXS_VERSION=\”2.36\” -fPIC “-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE” Expat.c
Expat.xs:12:19: error: expat.h: No such file or directory
Expat.xs:60: error: expected specifier-qualifier-list before ‘XML_Parser’

To make a long story short, the following was the quick fix…

yum install expat-devel