web-dev-qa-db-ja.com

cygwinで「コンパイラが実行可能ファイルを生成できませんでした」というGemのインストールに失敗する

cygwinに複数のgemをインストールしようとすると、次のエラーが発生し続けます:/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

私はグーグルで見つけることができるすべてのものを試しましたが、そのうちのいくつかは実際に機能します:

  • Cygwinセットアップを介してgemに対応するcygwinパッケージをインストールする
  • 失敗したgemに応じて、さらにcygwinパッケージをインストールする

しかし、この非常に具体的な例では、何が欠けているのかを見つけることができませんでした...

3
Camusensei

このエラーの解決策は、mkmf.logファイル(私にとっては/cygdrive/d/d/Documents/.gem/Ruby/extensions/x86_64-cygwin/ffi-1.9.8/mkmf.log)を調べて、欠落しているライブラリを確認することでした(そしてそのようなすべてのエラーに対するものです)。

私の場合、-lcrypt-lgmpが失敗していたので、libcrypt-devellibgmp-develを「cygwin-setup」する必要がありました。

7
Camusensei