【问题标题】:Thrift Ruby gem节俭的红宝石
【发布时间】:2013-11-08 02:55:26
【问题描述】:

我这辈子都无法成功运行“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。有任何想法吗? 谢谢。

【问题讨论】:

  • @AlejandroCárdenas 请接受其中一个答案。这些辛勤工作的人及时为您提供帮助,只需单击复选标记图标即可,谢谢
  • @nhed 对不起,我没有意识到我没有!现在完成。

标签: ruby thrift osx-mavericks thrift-protocol


【解决方案1】:

目前的问题可以在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'

【讨论】:

  • 也为我工作!我运行了bundle config 命令,然后再次运行bundle install,效果很好。
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

    以下应该安装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\"

    【讨论】:

    • 帮了我谢谢
    【解决方案4】:

    我没有使用 cppflags 的解决方法,而是提交了一个修复程序,该修复程序检查 __has_builtin(strlcpy) 并且如果系统上没有内置函数但定义了 strlcpy,那么它会像以前一样使用外部变量。适用于 os x 10.8、10.9、centos、ubuntu、...

    【讨论】:

      【解决方案5】:

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

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

      它对我有用,谢谢。

      【讨论】:

        猜你喜欢
        • 2019-08-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多