Compile Errors Installing Ruby-Xslt and Libxml-Ruby Gems

I was setting up a new server for a client yesterday and was beating my head getting a few gems install.If you are having issues installing the ruby-xslt and ruby-xml gems on linux (I was on CentOS 5.1), make sure the developer libraries of libxml and xslt are installed. I had the rpms installed, but not the developer versions.

For Red Hat based builds, you can do the following:

yum install libxml2-devel

yum install xslt-devel

Then you can install the gems.

gem install libxml-ruby

gem install ruby-xslt

Here is what the failure looked like for gem install ruby-xslt:

gem install ruby-xslt
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-xslt:
	ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install ruby-xslt
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetFile() in -lxslt... no
checking for exsltRegisterAll() in -lexslt... no
extconf.rb:4: command not found: xslt-config --cflags
creating extconf.h
creating Makefile
/usr/local/lib/ruby/1.8/mkmf.rb:1102: warning: global variable `$preload' not initialized

make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-linux -I. -DRUBY_EXTCONF_H=\"extconf.h\"  -fPIC -g -Wall -I/usr/include/libxml2  -g -O2 -DUSE_ERROR_HANDLER -DUSE_EXSLT  -c xslt_lib.c
In file included from xslt_lib.c:19:
xslt.h:36:27: error: libxslt/extra.h: No such file or directory
xslt.h:37:26: error: libxslt/xslt.h: No such file or directory
xslt.h:38:35: error: libxslt/xsltInternals.h: No such file or directory
xslt.h:39:31: error: libxslt/transform.h: No such file or directory
xslt.h:40:31: error: libxslt/xsltutils.h: No such file or directory
xslt.h:41:29: error: libxslt/imports.h: No such file or directory
xslt.h:44:30: error: libexslt/exslt.h: No such file or directory
In file included from xslt.h:52,
                 from xslt_lib.c:19:
parser.h:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘parse_xsl’
parser.h:25: error: expected ‘)’ before ‘xmlDocPtr’
In file included from xslt.h:54,
                 from xslt_lib.c:19:
extfunc.h:22:32: error: libxslt/extensions.h: No such file or directory
In file included from xslt_lib.c:19:
xslt.h:88: error: expected specifier-qualifier-list before ‘xsltStylesheetPtr’
xslt_lib.c: In function ‘ruby_xslt_free’:
xslt_lib.c:29: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:30: warning: implicit declaration of function ‘xsltFreeStylesheet’
xslt_lib.c:30: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_mark’:
xslt_lib.c:53: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:53: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:55: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:55: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c: In function ‘ruby_xslt_new’:
xslt_lib.c:80: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:82: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:83: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:85: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:86: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c: In function ‘ruby_xslt_xml_obj_set’:
xslt_lib.c:136: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c: In function ‘ruby_xslt_xsl_obj_set’:
xslt_lib.c:231: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:233: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:233: warning: implicit declaration of function ‘parse_xsl’
xslt_lib.c:234: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_serve’:
xslt_lib.c:291: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:293: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:296: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:297: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:299: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:300: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:306: warning: implicit declaration of function ‘parse’
xslt_lib.c:306: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:306: warning: assignment makes pointer from integer without a cast
xslt_lib.c:308: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:309: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:311: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:312: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:315: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:316: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:320: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c: In function ‘ruby_xslt_parameters_set’:
xslt_lib.c:425: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:427: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:428: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:429: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c: In function ‘ruby_xslt_media_type’:
xslt_lib.c:453: error: ‘xsltStylesheetPtr’ undeclared (first use in this function)
xslt_lib.c:453: error: (Each undeclared identifier is reported only once
xslt_lib.c:453: error: for each function it appears in.)
xslt_lib.c:453: error: expected ‘;’ before ‘vXSLTSheet’
xslt_lib.c:457: error: ‘vXSLTSheet’ undeclared (first use in this function)
xslt_lib.c:457: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_reg_function’:
xslt_lib.c:474: warning: implicit declaration of function ‘xsltRegisterExtModuleFunction’
xslt_lib.c: In function ‘ruby_xslt_to_s’:
xslt_lib.c:485: error: ‘xsltStylesheetPtr’ undeclared (first use in this function)
xslt_lib.c:485: error: expected ‘;’ before ‘vXSLTSheet’
xslt_lib.c:491: error: ‘vXSLTSheet’ undeclared (first use in this function)
xslt_lib.c:491: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘Init_xslt_lib’:
xslt_lib.c:544: error: ‘xsltMaxDepth’ undeclared (first use in this function)
xslt_lib.c:545: error: ‘XSLT_MAX_SORT’ undeclared (first use in this function)
xslt_lib.c:546: error: ‘xsltEngineVersion’ undeclared (first use in this function)
xslt_lib.c:547: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)
xslt_lib.c:548: error: ‘xsltLibxmlVersion’ undeclared (first use in this function)
xslt_lib.c:549: error: ‘XSLT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:550: error: ‘XSLT_DEFAULT_VENDOR’ undeclared (first use in this function)
xslt_lib.c:551: error: ‘XSLT_DEFAULT_VERSION’ undeclared (first use in this function)
xslt_lib.c:552: error: ‘XSLT_DEFAULT_URL’ undeclared (first use in this function)
xslt_lib.c:553: error: ‘XSLT_LIBXSLT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:554: error: ‘XSLT_NORM_SAXON_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:555: error: ‘XSLT_SAXON_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:556: error: ‘XSLT_XT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:557: error: ‘XSLT_XALAN_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:584: warning: implicit declaration of function ‘xsltSetGenericErrorFunc’
xslt_lib.c:588: warning: implicit declaration of function ‘exsltRegisterAll’
make: *** [xslt_lib.o] Error 1

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/ruby-xslt-0.9.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/ruby-xslt-0.9.5/ext/xslt_lib/gem_make.out

11 responses to “Compile Errors Installing Ruby-Xslt and Libxml-Ruby Gems”

  1. forumf says:

    Hi,

    I am getting error while Installing libxml gem
    can u send me the solution to solve this problem
    please send me to this mail ID forumf@yahoo.co.in

    root@admin-desktop:~# gem install -r libxml-ruby
    Updating metadata for 792 gems from http://gems.rubyforge.org
    …………………………………………………………………….. …………………………………………………………………….. …………………………………………………………………….. …………………………………………………………………….. …………………………………………………………………….. …………………………………………………………………….. ……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………
    complete
    Building native extensions. This could take a while…
    ERROR: Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.8 extconf.rb install -r libxml-ruby
    checking for socket() in -lsocket… no
    checking for gethostbyname() in -lnsl… yes
    checking for atan() in -lm… no
    checking for atan() in -lm… yes
    checking for inflate() in -lz… yes
    checking for iconv_open() in -liconv… no
    checking for libiconv_open() in -liconv… no
    checking for libiconv_open() in -llibiconv… no
    checking for iconv_open() in -llibiconv… no
    checking for iconv_open() in -lc… yes
    checking for xmlParseDoc() in -lxml2… no
    checking for xmlParseDoc() in -llibxml2… no
    checking for /opt/lib() in -lxml2… no
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers. Check the mkmf.log file for more
    details. You may need configuration options.

    Provided configuration options:
    –with-opt-dir
    –without-opt-dir
    –with-opt-include
    –without-opt-include=${opt-dir}/include
    –with-opt-lib
    –without-opt-lib=${opt-dir}/lib
    –with-make-prog
    –without-make-prog
    –srcdir=.
    –curdir
    –ruby=/usr/bin/ruby1.8
    –with-iconv-dir
    –without-iconv-dir
    –with-iconv-include
    –without-iconv-include=${iconv-dir}/include
    –with-iconv-lib
    –without-iconv-lib=${iconv-dir}/lib
    –with-xml2-dir
    –without-xml2-dir
    –with-xml2-include
    –without-xml2-include=${xml2-dir}/include
    –with-xml2-lib
    –without-xml2-lib=${xml2-dir}/lib
    –with-zlib-dir
    –without-zlib-dir
    –with-zlib-include
    –without-zlib-include=${zlib-dir}/include
    –with-zlib-lib
    –without-zlib-lib=${zlib-dir}/lib
    –with-socketlib
    –without-socketlib
    –with-nsllib
    –without-nsllib
    –with-mlib
    –without-mlib
    –with-mlib
    –without-mlib
    –with-zlib
    –without-zlib
    –with-iconvlib
    –without-iconvlib
    –with-iconvlib
    –without-iconvlib
    –with-libiconvlib
    –without-libiconvlib
    –with-libiconvlib
    –without-libiconvlib
    –with-clib
    –without-clib
    –with-xml2lib
    –without-xml2lib
    –with-libxml2lib
    –without-libxml2lib
    –with-xml2lib
    –without-xml2lib
    extconf failure: need libxml2.

    Install the library or try one of the following options to extconf.rb:

    –with-xml2-dir=/path/to/libxml2
    –with-xml2-lib=/path/to/libxml2/lib
    –with-xml2-include=/path/to/libxml2/include

    Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.5.4 for inspection.
    Results logged to /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.5.4/ext/libxml/gem_make.out

  2. gbenedict says:

    @forumf – Make sure you have libxml2 and the libxml2 development libraries installed. It cannot find them.

    With CentOS and RHEL this is:

    yum install libxml2-devel

  3. Raven says:

    Hi!

    I’ve tried exactly what you suggested but it seems my centos can’t find xslt-devel, where can it be found?

    Thanks.

  4. gbenedict says:

    You may have to get it from the centosplus repo.

  5. JacksonT says:

    I got it with:

    yum install libxslt-devel

  6. kajaco2 says:

    Thank you. This solved a problem installing mechanize on Ubuntu.

  7. Amit Solanki says:

    Thanks for the post. It really helped.

  8. Eugene says:

    Thank you!!!! Exactly what I was searching for!

  9. Arun Kumar Arjunan says:

    Thank you… That worked well..

  10. yum install libxslt-devel fixed it for me on CentOS

  11. phanindra says:

    installed libxml devel on fedora but the problem still exist, you know any solution for this?

Leave a Reply