如何在没有'extconf failure: need libxml2'的情况下安装Ruby Gem Libxml?

5

我目前正在尝试安装一个Ruby Gem,但是由于extconf说它需要libxml,所以当我按照这些说明安装libxml时(其中包括这些关于Ruby Dev Kit安装的说明),我得到以下输出:

$ gem install libxml-ruby --platform x86-mswin32-60
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:/Ruby/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... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
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.

Provided configuration options:
    --with-opt-dir
--8<--
    --with-xml2lib
    --without-xml2lib
 extconf failure: need libxml2.

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

  --with-xml2-config=/path/to/xml2-config
  --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 c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2 for inspection.
Results logged to c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2/ext/libxml/gem_make.out

我正在使用Windows 7 x64安装,使用minGW32-shell/git进行安装。安装失败,并在Windows ruby-enhanced命令提示符中显示相同的消息。

顺便说一下:

$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

$ git --version
git version 1.7.6.msysgit.0

$ gem -v
1.8.10

这个问题的答案解决了问题:https://dev59.com/kU7Sa4cB1Zd3GeqP0Avn - Zaz
我错过了这个评论。你应该把这个链接发表为答案,这样其他人就可以轻松地看到答案。 - Kelvin
4个回答

1
我本来是想把这个作为评论,但是被要求将其发布为答案以便更容易被看到:
这个问题的答案解决了我的问题:libxml-ruby failed to load at x86_64

1
你应该尝试使用 nokogiri gem 替代使用 libxml-ruby。它的安装包含预编译的 libxml2 dlls,因此您不必担心自己构建它。
Nokogiri 的 API 与 libxml-ruby 不同,但我相信你会找到相同的功能。
如果 libxml-ruby 是其他 gem 或应用程序的依赖项,则可能无法使用 nokogiri。你想做什么?

0

首先尝试使用;
yum install -y libxml2 libxml2-devel

如果需要libxslt,则使用
yum install -y libxslt libxslt-devel


0

尝试运行

yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

那应该可以工作了


对我来说仍然有用,谷歌搜索真是太棒了。谢谢。 - penner
在Ubuntu上,可以使用命令sudo apt-get install libxml2-dev进行安装。 - Eli Rose

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接