错误:安装ffi时出错:错误:无法构建gem原生扩展

red*_*ils 9 macos makefile file ffi

我在Mac 64位中收到此错误,并在机器上安装了xcode.

Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

/Users/jreddy/.rvm/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... no
checking for ruby_thread_has_gvl_p()... no
checking for ruby_native_thread_p()... no
checking for rb_thread_call_with_gvl()... no
creating extconf.h
creating Makefile

make
sh: make: command not found
Run Code Online (Sandbox Code Playgroud)

Fer*_*ndo 25

很大一部分用户登陆这个答案是为了更新Xcode Command Line Tools。实现这一目标的最简单方法是删除旧版本的工具,然后安装新版本。

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Run Code Online (Sandbox Code Playgroud)

将出现一个弹出窗口并指导您完成其余的过程。

毕竟,如果xcode安装正确,您仍然有问题,请尝试像这样安装 ffi:

gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
Run Code Online (Sandbox Code Playgroud)


Her*_*aña 13

这对我有用: brew link libffi --force


Mat*_*lly 9

我使用自制软件,所以在我brew install libffi为我安装了gem 之后.我有Xcode 4.2工具激活(使用xcode-select).我必须关闭并打开一个新的终端窗口,用于家庭酿造的安装,以便宝石安装识别.但我只能使用ruby 1.8.7而不是1.9.3(使用rvm).


sur*_*rga 6

另一个版本的答案,如果你使用brew 安装 libffi 那么仍然不起作用。你可以尝试这样做:

$ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.2.14/lib/pkgconfig/
$ gem install ffi
Run Code Online (Sandbox Code Playgroud)

  • 这个对我有帮助(其他选项没有) (3认同)

lig*_*yrs 0

我在 OS X Lion 上遇到了同样的问题,并通过执行以下操作解决了它:

sudo port install libffi
Run Code Online (Sandbox Code Playgroud)