15

我正在尝试使用以下命令安装 hpricot:

>gem install hpricot -v 0.8.2
Building native extensions.  This could take a while...
ERROR:  Error installing hpricot:
    ERROR: Failed to build gem native extension.

C:/Ruby19/bin/ruby.exe extconf.rb checking for stdio.h... * 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:/Ruby19/bin/ruby C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:362:in try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:431:intry_cpp' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:809:in block in have_header' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:668:inblock in checking_for' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:274:in block (2 levels) in postpone' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:248:inopen' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:274:in block in postpone' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:248:inopen' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:270:in postpone' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:667:inchecking_for' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:808:in have_header' from extconf.rb:2:in'

Gem files will remain installed in C:/Ruby19/lib/ruby/gems/1.9.1/gems/hpricot-0.8.2 for inspection. Results logged to C:/Ruby19/lib/ruby/gems/1.9.1/gems/hpricot-0.8.2/ext/fast_xs/gem_make.out

它提到我需要安装“开发工具”,但我不知道它指的是什么。有什么建议么?

4

5 回答 5

54

尝试:

gem install hpricot --platform=mswin32
于 2010-02-12T10:57:54.200 回答
6

在 ruby​​installer.org/downloads 安装 devkit

于 2009-11-13T06:46:42.393 回答
4

执行以下命令,它可以工作:

gem install hpricot --platform=mswin32
于 2010-09-22T18:40:32.700 回答
2

其他人可能会觉得有用的附加说明,来自我最近尝试使用 Ruby devkit 在 Windows 上安装:

要安装 devkit,将 bin 和 devkit 目录解压缩到 Ruby 目录,这将在 Ruby bin 中放置一些文件,在 Ruby 目录中放置一个 devkit 目录。然后,按照说明,在 fstab 文件中设置 mingw 的正确位置。

在我的例子中,一些 gem,即 Hpricot 和 Ruby-Debug19,即使正确安装了 devkit,也不会安装在我的系统上,因为创建 makefile 时出错。我最终将最新版本的 mingw 与 SourceForge 分开安装,然后将“ ruby19/devkit/msys/1.0.11/etc”目录中的 fstab 文件更改为指向我安装 mingw 的目录。然后正确安装了两个 gem。

于 2010-01-31T21:03:02.533 回答
-3

执行以下命令:

gem install hpricot
于 2011-12-24T03:32:55.080 回答