【问题标题】:Having trouble installing libxml-ruby on windows在 Windows 上安装 libxml-ruby 时遇到问题
【发布时间】:2015-11-13 17:42:40
【问题描述】:

首先感谢您的宝贵时间。

我在 Windows 8 操作系统上安装 libxml-ruby 时遇到了一些问题。我已经安装了 ruby​​,并且想专门使用 libxml 来修改 xml,因为我团队的其他成员已经开始使用 libxml。问题是他们使用的是linux,而我在windows上。我可以尝试将所有内容都放在虚拟机上,但我认为我不需要这样做。

他们在 linux 上安装也有问题,但他们的解决方案和问题与我的不同。

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

我已尝试安装 zlib(二进制文件)并指向 zlib 二进制文件。 这并没有真正的帮助。

所以现在我在谷歌搜索:)

【问题讨论】:

    标签: ruby-on-rails ruby windows


    【解决方案1】:

    好吧,我终于厌倦了自己遇到这个问题(并最终放弃并转向虚拟机)。所以我花了一些时间摆弄,终于找到了一个可靠的方法来在 Windows 上安装 Ruby(目前为 2.2.3)和 libxml-ruby。

    1. 从 ruby​​installer.org 为您的架构下载并安装最新的 Ruby
    2. 从同一页面下载匹配的 DevKit
    3. 提取 DevKit 并按照设置说明进行操作,尤其是 step 4
    4. zlib1.dll<ruby_install_dir>/bin复制到<ruby_install_dir>/lib
    5. 下载MinGW iconv package并将mingw64/lib中的所有内容提取到<ruby_install_dir>/lib
    6. 下载适用于 Windows 的 libxml(见下文)。将其lib 的内容提取到您的<ruby_install_dir>/lib 将其include 目录的内容提取到<ruby_install_dir>/include
    7. 幸运的是,gem install libxml-ruby 现在应该可以工作了,但您可能不得不尝试一些不同的安装程序参数。最终我需要gem install libxml-ruby -- with-xml2-include=C:\Ruby22-x64\include\libxml2 --with-iconv-include=C:\Ruby22-x64\include

    由于 StackOverflow 只允许我在答案中发布两个链接;

    我在
    https://forge.imag.fr/frs/?group_id=184&release_id=320 找到了适用于 windows 的 64 位版本的 libxml

    另一种可能是 ftp://ftp.zlatkovic.com/libxml/64bit/

    但两者似乎都不是官方来源,因此不能保证当您阅读本文时它会出现;)

    【讨论】:

    • 很好的答案,我能够在此基础上完成它。几个小的更正: * 您需要在某处安装 iconv 标头 * 构建 gem 时,您必须在额外的 -- 之后传递 --with-xml2-include 和 --with-iconv-include 参数。实际命令看起来像gem install libxml-ruby -- --with-xml2-include=C:\Ruby22-x64\include\libxml2 --with-iconv-include=C:\Ruby22-x64\include * 最新版本的 libxml-ruby 似乎不适用于 Ruby 2.0,我使用的是 2.7 版
    • 我需要切换到 libxml-ruby 2.9.0-x64-mingw32 rubygems.org/gems/libxml-ruby/versions/2.9.0-x64-mingw32 在使用 Ruby 2.7.5 在 Windows 11 上执行上述步骤后工作!重要提示:使用 -v2.9.0 更改 gems 版本……这对我来说很重要。
    【解决方案2】:

    没关系。

    我在互联网上进行了一次旅行,并决定只使用虚拟机并在 linux 上运行 ruby​​。耶 1 小时设置....

    我的旅程到此结束 http://rubyonwindowsguides.github.io/book/ch02-05.html

    感谢阅读。

    【讨论】:

      猜你喜欢
      • 2012-07-29
      • 2015-04-01
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-13
      • 2014-04-20
      相关资源
      最近更新 更多