ruby - 错误 : Failed to build gem native extension (ruby extconf. rb): Mac OSX

标签 ruby macos gem native-code

<分区>

我正在尝试安装一个 gem,但出现了这个错误,这是我自己和 gem 作者以前从未见过的。我该如何解决这个问题?

Davids-MacBook-Pro:web david$ sudo /usr/bin/gem install compass --pre
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing compass:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:303:5: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
                                  ^
1 warning generated.
compiling ClosurePool.c
compiling DataConverter.c
DataConverter.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling DynamicLibrary.c
compiling ffi.c
compiling Function.c
Function.c:479:33: warning: incompatible pointer types passing 'VALUE (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-pointer-types]
    rb_thread_call_with_gvl(callback_with_gvl, &cb);
                            ^~~~~~~~~~~~~~~~~
Function.c:102:46: note: passing argument to parameter 'func' here
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
                                         ^
Function.c:563:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
    rb_thread_call_without_gvl(async_cb_wait, &w, async_cb_stop, &w);
    ^
Function.c:738:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
compiling FunctionInfo.c
compiling LastError.c
compiling LongDouble.c
compiling MappedType.c
compiling MemoryPointer.c
compiling MethodHandle.c
compiling Platform.c
compiling Pointer.c
compiling Struct.c
compiling StructByReference.c
compiling StructByValue.c
compiling StructLayout.c
compiling Thread.c
compiling Type.c
compiling Types.c
compiling Variadic.c
linking shared-object ffi_c.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [ffi_c.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/ext/ffi_c/gem_make.out

最佳答案

如果这发生在 OSX Mavericks 中,请确保通过运行以下命令安装命令行工具。

旧版本的 OSX 和 XCode 在 XCode IDE 本身中安装了命令行工具。在 OSX Mavericks 中,我必须运行以下命令来修复我的命令行工具,以便我可以使用 native 扩展安装 ruby​​gems。

$ sudo xcode-select --install
$ xcode-select --print-path
/Library/Developer/CommandLineTools

关于ruby - 错误 : Failed to build gem native extension (ruby extconf. rb): Mac OSX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23429145/

相关文章:

ruby-on-rails - 使用 Roo gem 读取单元显示数据

c# - 在 mac 上用 c# 启动一个外部进程

macos - 在 Alpine 脉上使用Cuda编译OpenCV时发生链接错误

ruby - 如何使 gem install 命令仅在未安装或需要更新时安装

ruby - 安装 RedCloth 时出错

ruby - 如何从代理后面更新 Ruby Gems (ISA-NTLM)

ruby - 正则表达式的 o 修饰符是什么意思?

macos - Mac Os 中的 JavaFX 应用程序名称

ruby-on-rails - 在 rails 中使用 mustache View 模板的最简单方法是什么?

ruby - 是否存在将多个社交网络 API 抽象为一个简单 API 的 Ruby gem?