我正在尝试使用以下命令安装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:in
try_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:in
block 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:in
open'
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:in
open'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:270:in postpone'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:667:in
checking_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
它提到我需要安装“开发工具”,但我不知道它指的是什么。有什么建议吗?
答案 0 :(得分:54)
尝试:
gem install hpricot --platform=mswin32
答案 1 :(得分:6)
在rubyinstaller.org/downloads
上安装devkit答案 2 :(得分:4)
执行以下命令,它可以工作:
gem install hpricot --platform=mswin32
答案 3 :(得分:2)
我最近尝试使用Ruby devkit在Windows上安装时,其他人可能会觉得有用的其他注意事项:
要安装devkit,需要将bin和devkit目录解压缩到Ruby目录中,该目录将在Ruby bin中放置一些文件,在Ruby目录中放置devkit目录。然后,根据说明,在fstab文件中为mingw设置正确的位置。
就我而言,由于创建makefile时出错,即使安装了devkit,一些宝石,即Hpricot和Ruby-Debug19也不会安装在我的系统上。我最终分别从SourceForge安装了最新版本的mingw,然后将“ruby19/devkit/msys/1.0.11/etc
”目录中的fstab文件更改为指向我安装mingw的目录。然后两个宝石都正确安装。
答案 4 :(得分:-3)
执行以下命令:
gem install hpricot