Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Error installing ffi: ERROR: Failed to build gem native extension

Tags:

Got the DevKit installed and re-ran the ffi install….got this as an output:

C:\Documents and Settings\******>gem install ffi Temporarily enhancing PATH to include DevKit... Building native extensions.  This could take a while... ERROR:  Error installing ffi:         ERROR: Failed to build gem native extension.          C:/Ruby192/bin/ruby.exe extconf.rb checking for ffi.h... no checking for ffi.h in /usr/local/include... no checking for rb_thread_blocking_region()... yes checking for ruby_thread_has_gvl_p()... yes checking for ruby_native_thread_p()... yes checking for rb_thread_call_with_gvl()... yes creating extconf.h creating Makefile make C:/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_ffi_c'"  > ffi_c-i386-mingw32.def gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/include/ruby-1 .9.1/ruby/backward -I/C/Ruby192/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extcon f.h\"    -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith - Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-declaration-a fter-statement   -o AbstractMemory.o -c AbstractMemory.c In file included from AbstractMemory.c:28:0: compat.h:65:20: warning: extra tokens at end of #ifndef directive compat.h:69:24: warning: extra tokens at end of #ifndef directive In file included from AbstractMemory.h:29:0,                  from AbstractMemory.c:29: Types.h:68:17: fatal error: ffi.h: No such file or directory compilation terminated. make: *** [AbstractMemory.o] Error 1   Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.1 0 for inspection. Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.10/ext/ffi_c/gem_m ake.out _________________________________________________________________________________ 

Not sure how to deal with this issue. Kindly help.

like image 840
user1007520 Avatar asked Oct 21 '11 16:10

user1007520


People also ask

What is FFI on Mac?

FFI stands for “Foreign Function Interface”. It's a way to use functions defined in other programming languages.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


2 Answers

The gem install ffi fails due to the gem trying to build a bundled copy of libffi, which does not work due to assumptions that /usr/bin/env exists and too old libffi copy.

However, you can build the ffi gem against the system libffi - install the packages:

apt install clang make ruby-dev libffi-dev 

After that the ffi gem should build:

gem install ffi 
like image 180
ElS arekh Avatar answered Oct 13 '22 02:10

ElS arekh


Version 1.0.10 has issues compiling on windows.

You can use the 1.0.9

gem install ffi --version='1.0.9' 
like image 39
tommasop Avatar answered Oct 13 '22 01:10

tommasop