【问题标题】:compile Ruby 2.0 errors without rvm or rbenv , `readline.c:1886:26: error: 'Function' undeclared (first use in this function)`编译没有 rvm 或 rbenv 的 Ruby 2.0 错误,`readline.c:1886:26: error: 'Function' undeclared (first use in this function)`
【发布时间】:2014-05-06 07:42:43
【问题描述】:

我想安装 gitlab,不建议使用任何 ruby​​ 版本管理器。 但是

这是我的操作系统Linux dqa-dev 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux

linking shared-object psych.so
installing default psych libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/psych'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/pty'
compiling pty.c
pty.c: In function 'chfunc':
pty.c:143:12: warning: ignoring return value of 'seteuid', declared with attribute warn_unused_result [-Wunused-result]
     seteuid(getuid());
            ^
linking shared-object pty.so
installing default pty libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/pty'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
compiling cparse.c
linking shared-object racc/cparse.so
installing default cparse libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/readline'
compiling readline.c
readline.c: In function 'Init_readline':
readline.c:1886:26: error: 'Function' undeclared (first use in this function)
     rl_pre_input_hook = (Function *)readline_pre_input_hook;
                          ^
readline.c:1886:26: note: each undeclared identifier is reported only once for each function it appears in
readline.c:1886:36: error: expected expression before ')' token
     rl_pre_input_hook = (Function *)readline_pre_input_hook;
                                    ^
readline.c: At top level:
readline.c:530:1: warning: 'readline_pre_input_hook' defined but not used [-Wunused-function]
 readline_pre_input_hook(void)
 ^
make[2]: *** [readline.o] Error 1
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/readline'
make[1]: *** [ext/readline/all] Error 2
make[1]: Leaving directory `/home/poc/ruby-2.0.0-p451'
make: *** [build-ext] Error 2

【问题讨论】:

    标签: ruby ubuntu-12.04 ubuntu-14.04


    【解决方案1】:

    我也有 Ubuntu 14.04,我必须让它工作。分享我所做的,以防万一它对你有用。

    我修补了文件ext/readline/readline.c 替换行1886

    rl_pre_input_hook = (Function *)readline_pre_input_hook;
    

    rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
    

    然后我又尝试了一次,它成功了。

    来源:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741825

    【讨论】:

    • 谢谢。另外值得一提的是,ext 文件夹位于您的 rvm/rinstalled ruby​​ 版本文件夹中
    【解决方案2】:

    我在尝试使用 rbenv 安装 ruby​​-2.0.0-p247 时也遇到了这个问题。使用this patch 可以节省一些时间。

    你可以这样运行它:

    curl -fsSL https://gist.github.com/ference/d3d4cbbe18309a91ad9b/raw/267ea89fa145c536967831e1af4dea030297b53e/ruby-2.0.0-p247.patch | rbenv install --patch 2.0.0-p247
    

    【讨论】:

      【解决方案3】:

      这是我在 Ubuntu 14.04 服务器版上的解决方案。

      我需要加下划线

      sudo apt-get install libreadline6 libreadline6-dev

      然后,问题就解决了。

      【讨论】:

      • 这将是更清洁的解决方案;但我使用的是相同版本的 Ubuntu,并且这些软件包已经安装。这对我不起作用:(虽然巴勃罗的回答确实有效。
      【解决方案4】:

      https://github.com/sstephenson/ruby-build/issues/690 找到解决方案。实际上缺少的是 libffi-dev。我在 Ubuntu 12.04 上试过,成功了。

      sudo apt-get install libffi-dev
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-23
        • 2011-08-06
        • 1970-01-01
        • 1970-01-01
        • 2014-05-18
        • 2022-12-02
        • 2018-05-24
        • 2022-12-02
        相关资源
        最近更新 更多