1

First of all thank you for your time.

I've been having some trouble installing libxml-ruby on my windows 8 OS. I have ruby installed and want to use libxml specifically to modify xmls because other members of my team have already started with libxml. The problem is that they were using linux and I'm on windows. I could try to put everything on a vm but I don't think I should need to.

They had issues installing on linux too but their solution and problem was different from mine.

C:\dev\school\ece450\MyBPM>gem install libxml-ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
        ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... yes
checking for inflate() in -lz... no
checking for inflate() in -lzlib... no
checking for inflate() in -lzlib1... no
checking for inflate() in -llibz... 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=C:/Ruby200/bin/ruby
        --with-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-dir}/
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/
        --with-socketlib
        --without-socketlib
        --with-nsllib
        --without-nsllib
        --with-mlib
        --without-mlib
        --with-zlib
        --without-zlib
        --with-zliblib
        --without-zliblib
        --with-zlib1lib
        --without-zlib1lib
        --with-libzlib
        --without-libzlib
 extconf failure: need zlib

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/libxml-ru
by-2.7.0 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/li
bxml-ruby-2.7.0/gem_make.out

I have tried installing zlib (binaries) and pointing to the zlib binary. That didn't really help.

So now I'm googling :)

obesechicken13
  • 795
  • 1
  • 12
  • 24

2 Answers2

4

Alright, I finally got sick of running into this issue myself (and eventually giving up and moving to a VM). So I spent some time fiddling around and finally got a reliable way to get install Ruby (2.2.3 as of now) and libxml-ruby on Windows.

  1. Download and install the latest Ruby for your architecture from rubyinstaller.org
  2. Download the matching DevKit from the same page
  3. Extract the DevKit and follow the setup instructions, particularly step 4
  4. Copy zlib1.dll from <ruby_install_dir>/bin to <ruby_install_dir>/lib
  5. Download the MinGW iconv package and extract everything in mingw64/lib to <ruby_install_dir>/lib
  6. Download libxml for windows (see below). Extract the contents of its lib into your <ruby_install_dir>/lib and the contents of its include directory into <ruby_install_dir>/include
  7. With luck, gem install libxml-ruby should now work, but odds are you'll probably have to try some different arguments to the installer. Ultimately I needed gem install libxml-ruby -- with-xml2-include=C:\Ruby22-x64\include\libxml2 --with-iconv-include=C:\Ruby22-x64\include

Since StackOverflow only lets me post two links in an answer;

I found a 64 bit version of libxml for windows at
https://forge.imag.fr/frs/?group_id=184&release_id=320

Another possibility is ftp://ftp.zlatkovic.com/libxml/64bit/

but neither seem to be an official source, so no guarantees that it'll be around when you read this ;)

Wikk
  • 63
  • 1
  • 10
  • 1
    Great answer, I was able to make it through based on this. Couple of minor corrections: * You need to install the iconv headers somewhere * When building gems you have to pass the --with-xml2-include and --with-iconv-include parameters after an extra --. The actual command looks like `gem install libxml-ruby -- --with-xml2-include=C:\Ruby22-x64\include\libxml2 --with-iconv-include=C:\Ruby22-x64\include` * Latest version of libxml-ruby does not seem to work with Ruby 2.0, I used version 2.7 – Dan Macumber Oct 25 '16 at 19:51
  • I needed to switch to libxml-ruby 2.9.0-x64-mingw32 https://rubygems.org/gems/libxml-ruby/versions/2.9.0-x64-mingw32 Worked after I have been following the steps above on Windows 11 with Ruby 2.7.5! Important: change the gems version with -v2.9.0 ... this made a difference for me. – user2078148 Jan 26 '22 at 14:12
1

Nevermind.

I went on a journey through the internet and decided just to use a VM and run ruby on linux. Yay 1 hour setup....

Here's where my journey ended http://rubyonwindowsguides.github.io/book/ch02-05.html

Thanks for reading.

obesechicken13
  • 795
  • 1
  • 12
  • 24