如何安装 ruby​​ gem libxml 而不出现“extconf 失败:需要 libxml2”

发布于 2024-12-04 17:02:31 字数 2110 浏览 0 评论 0原文

我目前正在尝试安装 ruby​​ gem,但失败了,因为 extconf 说它需要 libxml,所以当我按照 这些 安装 libxml 的说明(其中包括 这些有关 ruby​​ 开发工具包安装的说明)我得到以下输出:

$ 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

我在使用我的 minGW32-shell/git 进行 Windows 7 x64 安装。安装失败,并显示来自 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

I'm currently trying to install a ruby gem which fails because extconf says it needs libxml, so when I follow these instructions to install libxml (which includes these instructions for the ruby dev kit installation) I get the following output:

$ 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

I'm on a Windows 7 x64 install using my minGW32-shell/git to install. The install fails with the same message from the windows ruby-enhanced command promt.

fwiw:

$ 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

り繁华旳梦境 2024-12-11 17:02:31

您应该尝试使用 nokogiri gem,而不是使用 libxml-ruby。它包含预编译的 libxml2 dll 作为安装的一部分,因此您不必担心自己构建它。

Nokogiri 的 API 与 libxml-ruby 的不同,但我确信您会发现相同的功能。

如果 libxml-ruby 是另一个 gem 或应用程序的依赖项,您可能无法使用 nokogiri。你想做什么?

You should try the nokogiri gem instead of using libxml-ruby. It includes the precompiled libxml2 dlls as part of the installation, so you don't have to worry about building it yourself.

Nokogiri's API is different from libxml-ruby's, but I'm sure you'll find the same functionality.

If libxml-ruby is a dependency for another gem or app, you probably can't use nokogiri. What are you trying to do?

ら栖息 2024-12-11 17:02:31

我将此作为评论,但被要求将其发布为可见性的答案:

此问题的答案解决了我的问题: libxml-ruby 在 x86_64 上加载失败

I had this as a comment, but was asked to post it as an answer for visibility:

The answer to this question solved my problem: libxml-ruby failed to load at x86_64

〆一缕阳光ご 2024-12-11 17:02:31

尝试运行

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

比它应该工作

Try to run

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

Than it should work

时光礼记 2024-12-11 17:02:31

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

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

try first with;
yum install -y libxml2 libxml2-devel

If libxslt needed, then
yum install -y libxslt libxslt-devel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文