'gem install ffi'在Mac OS X Yosemite 10.10.5上失败

时间:2016-04-28 12:15:23

标签: ruby-on-rails xcode rubygems

我正在尝试在我的macbook pro上的Mac OS X Yosemite 10.10.5上的RVM下设置一个RoR环境。 我需要安装的ruby版本是1.9.3-p194,因为它是我的软件开发项目所必需的。

到目前为止,我的Macbook上安装了以下软件:

RVM
ruby 1.9.3-p194
xcode v6.4 and the respective version of command line tools
Mac OS X version: 10.10.5 Yosemite

似乎我遇到了一个问题,即ffi gem(我项目的独立性)无法成功构建。

每当我尝试通过命令“gem install ffi -v'1.9.3'”安装gem时,我都会收到以下错误

MacBook-Pro:demo-project apple$ gem install ffi -v '1.9.3'
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

    /Users/apple/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20160428-1898-idt325.rb extconf.rb
checking for ffi_call() in -lffi... *** 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
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/apple/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
    --with-ffilib
    --without-ffilib
/Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
    from extconf.rb:20:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/apple/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.9.3 for inspection.
Results logged to /Users/apple/.rvm/gems/ruby-1.9.3-p194/extensions/x86_64-darwin-14/1.9.1/ffi-1.9.3/gem_make.out

我说我安装了xcode命令行工具,但是从下面给出的错误中注意到它给了我一个提示“你必须先安装开发工具”。

我没有安装它吗?我出于好奇而问自己。 然后我用Google搜索并找出了如何检查我是否安装了xcode命令行工具的方法。然后我启动了终端并发出了如下图所示的命令,结果确认已经安装了该软件。

MacBook-Pro:demo-project apple$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

这也是我的gcc版本:

MacBook-Pro:demo-project apple$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

我在网上搜索并尝试了很多解决方案,但遗憾的是,没有成功。 我们非常感谢任何建议让它发挥作用。

更新

我的mkmf.log

package configuration for libffi
cflags: -I/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include
ldflags: -L/usr/local/Cellar/libffi/3.0.13/lib
libs: -lffi

"/usr/local/bin/gcc-4.9 -o conftest -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin14.5.0 -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I. -I/usr/local/opt/libyaml/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE    -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include conftest.c  -L. -L/Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib -L/usr/local/opt/libyaml/lib -L. -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/Cellar/libffi/3.0.13/lib     -lffi -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

0 个答案:

没有答案