尝试安装多个宝石时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
我尝试了在 Google 上能找到的所有方法,其中一些确实有效,包括:
- 通过cygwin setup安装该gem对应的cygwin包
- 根据失败的 gem 安装更多 cygwin 包
但是对于这个非常具体的例子,我找不到缺少的东西......
答案1
解决这个错误的方法是(对于所有此类错误来说)查看文件mkmf.log
(对我来说/cygdrive/d/d/Documents/.gem/ruby/extensions/x86_64-cygwin/ffi-1.9.8/mkmf.log
),看看缺少哪些库。
就我而言,-lcrypt
和-lgmp
都失败了,所以我必须“cygwin-setup”libcrypt-devel
和libgmp-devel
。