节俭红宝石宝石

时间:2013-10-29 04:57:54

标签: ruby thrift osx-mavericks thrift-protocol

我不能,为了我的生活,成功运行“gem install thrift”,在构建gem的原生扩展时,事情就失败了;这是输出:

(acib708) ~ -> gem install thrift
Building native extensions.  This could take a while...
ERROR:  Error installing thrift:
    ERROR: Failed to build gem native extension.

    /Users/acib708/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for strlcpy() in string.h... yes
creating Makefile

make "DESTDIR="
compiling binary_protocol_accelerated.c
compiling bytes.c
compiling compact_protocol.c
compiling memory_buffer.c
compiling protocol.c
compiling strlcpy.c
                                           ^

(...)

In file included from strlcpy.c:20:
./strlcpy.h:28:15: error: conflicting types for '__builtin___strlcpy_chk'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
./strlcpy.h:28:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
4 errors generated.
make: *** [strlcpy.o] Error 1


Gem files will remain installed in /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1 for inspection.
Results logged to /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1/ext/gem_make.out

我在网上看到过很多类似的错误,但我还没有找到解决方案。我正在运行OS X 10.9,安装了新的rvm / ruby​​-2.0.0-p247。有任何想法吗? 感谢。

5 个答案:

答案 0 :(得分:58)

目前的问题可以在https://issues.apache.org/jira/browse/THRIFT-2219

找到

作为使用宝石的人的临时修复,您可以尝试将#define'ing _FORTIFY_SOURCE宏设置为0以使strlcpy成为函数而不是宏:

gem install thrift -- --with-cppflags='-D_FORTIFY_SOURCE=0'

或者如果你正在使用bundler,你可以通过以下方式在本地设置cflags:

bundle config build.thrift --with-cppflags='-D_FORTIFY_SOURCE=0'

答案 1 :(得分:6)

在OS 10.9.4上,以下命令对我有用

bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"

答案 2 :(得分:3)

而不是使用cppflags的变通方法我提交了一个检查__has_builtin(strlcpy)的修复程序,如果内置系统在系统上不可用但是定义了strlcpy,那么它会像以前一样使用externs。适用于os x 10.8,10.9,centos,ubuntu,......

答案 3 :(得分:0)

请编辑〜/ .bundle / config 文件,然后它看起来像这样:

---
BUNDLE_BUILD__THRIFT: "--with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value\""

它对我有用,谢谢。

答案 4 :(得分:0)

以下应该安装 gem。

gem install thrift -- --with-cppflags=\"-Wno-compound-token-split-by-macro\"

在 bundler 中,您需要执行以下操作,直到新的 ruby​​ 版本发布并修复了上述问题中的链接。

bundle config build.thrift --with-cppflags=\"-Wno-compound-token-split-by-macro\"