Gem installation failling with "The compiler failed to generate an executable file" on cygwin

3

1

Trying to install multiple gems on cygwin, I keep getting this error: /usr/share/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError)

This error is part of the full error message below:

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

I tried all things I could find on google, out of which some do actually work including:

  • Installing the cygwin package corresponding to the gem through cygwin setup
  • Installing more cygwin packages, depending on the failing gem

But for this very specific example, I could not find what was missing...

Camusensei

Posted 2015-06-03T09:40:50.890

Reputation: 201

Answers

7

The solution for this error was (and is for all such errors) to have a look at the mkmf.log file (for me, /cygdrive/d/d/Documents/.gem/ruby/extensions/x86_64-cygwin/ffi-1.9.8/mkmf.log) and see which libraries are missing.

In my case, -lcrypt and -lgmp were failing, so I had to "cygwin-setup" libcrypt-devel and libgmp-devel.

Camusensei

Posted 2015-06-03T09:40:50.890

Reputation: 201

Unfortunately, some libs are not available, like -lv8 or -ltokyocabinet so I had to give up. – Camusensei – 2015-06-05T14:07:34.943