无法在Windows中使用Cygwin安装Mechanize(错误:无法构建gem本机扩展。)

时间:2015-04-10 05:14:40

标签: ruby mechanize

我没有成功安装Mechanize 我目前的ruby版本2.0.0

这就是我得到的错误

$ gem install mechanize
Building native extensions.  This could take a while...
ERROR:  Error installing mechanize:
        ERROR: Failed to build gem native extension.

    /usr/bin/ruby.exe extconf.rb
checking for main() in -lstdc++... *** 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=/usr/bin/ruby
        --with-stdc++lib
        --without-stdc++lib
/usr/share/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/share/ruby/2.0.0/mkmf.rb:519:in `try_link0'
        from /usr/share/ruby/2.0.0/mkmf.rb:534:in `try_link'
        from /usr/share/ruby/2.0.0/mkmf.rb:720:in `try_func'
        from /usr/share/ruby/2.0.0/mkmf.rb:950:in `block in have_library'
        from /usr/share/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
        from /usr/share/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
        from /usr/share/ruby/2.0.0/mkmf.rb:310:in `open'
        from /usr/share/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
        from /usr/share/ruby/2.0.0/mkmf.rb:310:in `open'
        from /usr/share/ruby/2.0.0/mkmf.rb:336:in `postpone'
        from /usr/share/ruby/2.0.0/mkmf.rb:894:in `checking_for'
        from /usr/share/ruby/2.0.0/mkmf.rb:945:in `have_library'
        from extconf.rb:2:in `<main>'


Gem files will remain installed in /home/Dennis/.gem/ruby/gems/unf_ext-0.0.6 for inspection.
Results logged to /home/Dennis/.gem/ruby/gems/unf_ext-0.0.6/ext/unf_ext/gem_make.out

我试过这个solution,但不适合我。我仍然收到这个类似的错误。

我也安装了nokogiri。我想知道这里有什么问题......

1 个答案:

答案 0 :(得分:0)

要构建本机扩展,您需要安装开发工具包。

转到Ruby Installer download page,根据您的Ruby和系统版本下载开发套件,将套件安装到适当的目录,然后重新安装宝石。