Thrift Ruby gem

aci*_*708 12 ruby thrift thrift-protocol osx-mavericks

我不能,为了我的生活,成功运行"宝石安装节俭",在构建宝石的原生扩展时,事情就失败了; 这是输出:

(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
                                           ^
Run Code Online (Sandbox Code Playgroud)

(......)

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
Run Code Online (Sandbox Code Playgroud)

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

Gre*_*iez 59

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

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

gem install thrift -- --with-cppflags='-D_FORTIFY_SOURCE=0'
Run Code Online (Sandbox Code Playgroud)

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

bundle config build.thrift --with-cppflags='-D_FORTIFY_SOURCE=0'
Run Code Online (Sandbox Code Playgroud)

  • 也为我工作!我运行`bundle config`命令,然后再次运行`bundle install`,效果很好. (3认同)

小智 8

下面应该安装 gem。

gem install thrift -- --with-cppflags=\"-Wno-compound-token-split-by-macro\"
Run Code Online (Sandbox Code Playgroud)

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

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


小智 6

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

bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"
Run Code Online (Sandbox Code Playgroud)