Search code examples
rubywindowsrubygemslibxml2

Issue installing libxml-ruby for Windows Ruby version 2.3.3. Missing xmlParseDoc() in -lxml2


I have looked through most answers involving install issues with the libxml-ruby gem, and I got stuck on this issue with no solution. I am currently running Ruby 2.3.3.

This is the current command I am using:

gem install libxml-ruby -- --with-xml2-lib=C:\Ruby-2.3.3\lib --with-xml2-include=C:\Ruby-2.3.3\include

The resulting issue is:

checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,
/usr/local/include/libxml2,
/usr/include/libxml2... yes
checking for xmlParseDoc() 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.

xmlParseDoc() is in Parser.h, but is missing somewhere I cannot find. Has anyone else run into this same issue, and found a solution?


I got it working when I downgraded to libxml-ruby 2.7 with the same command. I would still like to figure out why the new version is unable to be installed. I eventually need 2.8.0 or above, which were causing this issue.


Solution

  • I finally found a solution. What worked for me is I first followed the instructions in this solution. After I had to go find some of the missing pieces from libiconv; I got those from here. I extracted its lib and include contents, into like the above solution (lib into Ruby lib, include into Ruby include). After I had to change #include <iconv.h> in encoding.h. This needed to be changed to #include <path-to-/iconv.h>, which was extracted into Ruby's include directory earlier. I was able to run gem install libxml-ruby -- with-xml2-include=C:/Ruby23/include/libxml2 --with-iconv-include=C:/Ruby23/include.