Gem 安装失败,在 cygwin 上显示“编译器无法生成可执行文件”

Cam*_*sei 3 windows cygwin ruby gcc gem

尝试在 上安装多个 gem cygwin,我不断收到此错误:/usr/share/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError)

此错误是以下完整错误消息的一部分:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby.exe -r ./siteconf20150603-27012-w371hi.rb extconf.rb
*** 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
        [...truncated...]
        --without-pkg-config
/usr/share/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/share/ruby/2.2.0/mkmf.rb:541:in `try_link0'
        from /usr/share/ruby/2.2.0/mkmf.rb:556:in `try_link'
        from /usr/share/ruby/2.2.0/mkmf.rb:637:in `try_ldflags'
        from /usr/share/ruby/2.2.0/mkmf.rb:1780:in `pkg_config'
        from extconf.rb:15:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /cygdrive/d/d/.gem/ruby/gems/ffi-1.9.8 for inspection.
Results logged to /cygdrive/d/d/.gem/ruby/extensions/x86_64-cygwin/ffi-1.9.8/gem_make.out
Run Code Online (Sandbox Code Playgroud)

我尝试了所有可以在 google 上找到的东西,其中一些确实有效,包括:

  • 通过cygwin setup安装gem对应的cygwin包
  • 根据失败的 gem 安装更多的 cygwin 包

但是对于这个非常具体的例子,我找不到丢失的东西......

Cam*_*sei 7

此错误的解决方案是(并且针对所有此类错误)查看mkmf.log文件(对我而言/cygdrive/d/d/Documents/.gem/ruby/extensions/x86_64-cygwin/ffi-1.9.8/mkmf.log)并查看缺少哪些库。

在我的情况下,-lcrypt并且-lgmp失败了,所以我不得不“cygwin-setup”libcrypt-devellibgmp-devel.