Sooji Sooji - 1 month ago 7x
Ruby Question

Issues installing libxml gem for ruby on windows

There are a few threads on questions similar to this, but none have proven effective. I attempted asking on the github page with no luck either.

When I attempt the standard command:

gem install libxml-ruby

I receive an error where the installer cannot find libxml2.dll. I found a stackoverflow thread with a similar issue and followed a user's guidelines here on where to grab the missing libraries and where to include them.

If I add arguments to the install command to point at the directories with the missing libraries using the following:

gem install libxml-ruby -- with-xml2-include=C:\Ruby200\include\libxml2 --with-iconv-include=C:\Ruby200\include

I now get an error where the installer can’t find a “iconv.h” header which is in my C:\Ruby200\include directory.

C:\Users\gonz102>gem install libxml-ruby -- with-xml2-include=C:/Ruby200/include
/libxml2 --with-iconv-include=C:/Ruby200/include
Temporarily enhancing PATH to include DevKit...
Building native extensions with: 'with-xml2-include=C:/Ruby200/include/libxml2 -
This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

C:/Ruby200/bin/ruby.exe extconf.rb with-xml2-include=C:/Ruby200/include/libx
ml2 --with-iconv-include=C:/Ruby200/include
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libx
ml2,/usr/local/include/libxml2,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... yes
checking for rb_io_bufwrite() in ruby/io.h... yes
creating extconf.h
creating Makefile

make "DESTDIR="
compiling libxml.c
In file included from C:/Ruby200/include/libxml2/libxml/parser.h:810:0,
from ruby_libxml.h:7,
from libxml.c:1:
C:/Ruby200/include/libxml2/libxml/encoding.h:28:19: fatal error: iconv.h: No suc
h file or directory
compilation terminated.
make: *** [libxml.o] Error 1

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/libxml-ru
by-2.9.0 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/libxml-ruby-2.9.0/ext/libx

If anyone has any suggestions on what to investigate next or possible solutions I'd greatly appreciate it. I've been stumped on this for over a long while, coming back to it whenever I run into a project with libxml and would gladly take any advice.

Many thanks.


I was unsuccessful with installing libxml version 2.9.0 but 2.7.0 worked just fine. I should specify I'm running windows 7 and Ruby 2.0 32 bit. Here is what I had to do:

-I followed Wik's response here, grabbing all the missing libraries from them mingw64. Admittedly, I'm not sure if I needed all of them, but I sort of took a shotgun approach here.

Added the following to my system path:


Executed the following in command line:

gem install libxml-ruby -v2.7.0 -- with-xml2-include:=C/Ruby200/include/libxml2 --with-iconv-include:=C:/Ruby200/include

After that, I the gem, at long last, installed and was actually usable.