错误:安装ffi时出错:错误:无法构建本地扩展宝石。

23

我在64位的Mac上遇到了这个错误,并且我的机器上已经安装了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

2
重新安装了Xcode工具!它起作用了。 - reddyonrails
你需要先安装开发工具。 请运行 xcode-select --install 命令,检查是否已安装 XCode 命令行工具。来源:https://github.com/ffi/ffi/issues/937#issuecomment-1073265562 - Chaki_Black
14个回答

0

我在OS X Lion上遇到了同样的问题,通过以下方法解决:

sudo port install libffi

MacPorts需要在系统级别上安装才能与sudo一起使用。 - lightyrs

0

我之前使用的是ree-1.8.7-2010.02,但安装一直无法成功。后来切换到ruby-1.9.2,安装就非常顺利了。


0
为了解决这个问题,我必须在我的~/.profile/~/.bash_profile中添加以下环境变量:
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"

添加这些后,我就能够安装ffi宝石了。

请注意,您可能需要先通过以下方式安装/设置Xcode SDK/库:

xcode-select --install
sudo xcodebuild -license
sudo xcode-select --switch /Applications/Xcode.app

0

首先,对我起作用的是:

gem install ffi -v '1.15.5' -- --with-cflags="-Wno-error=implicit-function-declaration"

然后:

gem pristine ffi --version 1.15.5

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接