关于Ruby Gem在Windows上安装,遇到编译问题的解决思路
转自:http://hi.baidu.com/kenrome/blog/item/d3803da859b485a7ca130c05.html
?
往往许多gem都是提供的源代码,当安装当本地时候会进行编译的过程。所以在Windows系统下,就经常遇到gem编译失败而导致安装的不成功。
我最近遇到就有安装 Hpricot, PageRankr两个gem的问题。
首先说一下Hpricot
在运行:?gem install hpricot
的时候,发生编译问题。然后试:
gem install hpricot --platform=mswin32
安装成功,这个问题就在于,gem源没有选择mswin32.
?
但是安装PageRank就没那么幸运了,遇到都是编译的问题,解决办法是参照:http://stackoverflow.com/questions/1718500/installing-hpricot-on-ruby-1-9-1-on-windows?中提到的,下载DevKit?rubyinstaller.org/downloads?提供的mingw环境安装。
?
安装Hpricot的错误代码:
Administrator@MOVEPC ~/Documents/NetBeansProjects/WebSpiderCode (master)
$ gem install hpricot
Building native extensions. ?This could take a while...
ERROR: ?Error installing hpricot:
?? ? ? ?ERROR: Failed to build gem native extension.
?
?? ? ? ?c:/Ruby187/bin/ruby.exe extconf.rb
checking for stdio.h... 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:/Ruby187/bin/ruby
?
?
Gem files will remain installed in c:/Ruby187/lib/ruby/gems/1.8/gems/hpricot-0.8.4 for inspection.
Results logged to c:/Ruby187/lib/ruby/gems/1.8/gems/hpricot-0.8.4/ext/fast_xs/gem_make.out
?
Administrator@MOVEPC ~/Documents/NetBeansProjects/WebSpiderCode (master)
$ gem install hpricot --platform=mswin32
Fetching: hpricot-0.8.4-i386-mswin32.gem (100%)
Successfully installed hpricot-0.8.4-x86-mswin32
1 gem installed
Installing ri documentation for hpricot-0.8.4-x86-mswin32...
Installing RDoc documentation for hpricot-0.8.4-x86-mswin32...
?
Administrator@MOVEPC ~/Documents/NetBeansProjects/WebSpiderCode (master)