简体   繁体   中英

Unable to install Mechanize using Cygwin in Windows ( ERROR: Failed to build gem native extension.)

I have been unsuccessful to install Mechanize My current ruby version 2.0.0

This is what the error I get

$ 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

I have tried this solution but is not working for me. I still receiving this similiar error.

I also have nokogiri installed. I wonder what is the problem here...

To build the native extensions, you need the development kit installed.

Go to the Ruby Installer download page , download the DEVELOPMENT KIT according to your Ruby and system version, install the kit to an appropriate directory and then reinstall the gem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM