节俭rubygem

我不能,为了我的生活,成功运行“gem安装节俭”,在构建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 `': Use RbConfig instead of obsolete and deprecated Config. extconf.rb:25:in `': 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。 有任何想法吗? 谢谢。

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

作为使用gems的人的临时修复,你可以尝试将#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' 

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

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

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

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

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

这对我有用,谢谢。