libxml-ruby and Windows

Posted by Pieter Bos Tue, 09 Oct 2007 12:41:25 GMT

So, my first post on movesonrails.com! You might not know me, but I am one of the Nedap Healthcare developers. Usually I don't work on Moves or even with ruby on rails, but I needed some functionality...

You might have seen a patch by Bart that allowed ActiveResource to be used with Libxml-ruby, with a dramatic performance increase. The downside was, you can't use libxml with Windows, limiting your applications to mac-os and linux. There was one build of libxml-ruby, which didn't really work, is an older version and missed some rather important files.

But now you can use libxml-ruby in windows! Just unpack this zip into your ruby directory, rename ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\xmlparser.so to xmlparser.s_ and you'll have libxml 0.5.2.0 !

If you'd rather had libxml-ruby 0.3.8.4, you can download this zip instead, or even 0.5.1.0

To achieve this, I spent a morning compiling libxml with mingw. Just forget the following if you just want to use this, but for the sake of future version, this is what i had to do:

1 . install mingw and MSYS in the standard directories (c:\mingw)

2 . download the ruby source and compile, in a different directory than c:\ruby:

./configure --with-prefix=c:/mingw/ruby
    make
    make install

3 . download the zlib, iconv and libxml sources

4 . compile all of them with :

./configure --with-prefix=c:/mingw
    make
    make install

5 . download libxml-ruby

6 . now, the tricky part. You won't have rake (you didn't compile it) so we have to do a trick. Go to your libxml-ruby source directory and type:

    /c/mingw/ruby/bin/ruby ext/xml/extconf.rb
    make
    make install

7 . everything has been compiled. Just copy these files:

    to ruby\bin:
    c:\mingw\bin\iconv-2.dll
    c:\mingw\bin\libxml2-2.dll
    
    to ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\xml:
    C:\MinGW\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\xml\libxml_so.o
    
    to ruby\lib\ruby\site_ruby\1.8\xml
    C:\MinGW\ruby\lib\ruby\site_ruby\1.8\xml\libxml.rb
    

have fun with a 20 times faster XML parser :)

update! versions 0.5.2.0 and 0.3.8.4 also available!

download 0.5.2.0 or 0.3.8.4

Tags , , , , ,  | 11 comments