编译没有rvm或rbenv的Ruby 2.0错误,`readline.c:1886:26:错误:'函数'未声明(首次在此函数中使用)

new*_*ike 10 ruby ubuntu-12.04 ubuntu-14.04

我想安装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
Run Code Online (Sandbox Code Playgroud)

Pab*_*res 39

我也有Ubuntu 14.04,我必须让它工作.分享我的所作所为,以防它适合你.

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

rl_pre_input_hook = (Function *)readline_pre_input_hook;
Run Code Online (Sandbox Code Playgroud)

rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
Run Code Online (Sandbox Code Playgroud)

然后我尝试再次制作它并且它有效.

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

  • 谢谢!这真的解决了这个问题. (4认同)

new*_*ike 2

这是我在 Ubuntu 14.04 Server 版本上的解决方案。

我需要安装下划线

sudo apt-get install libreadline6 libreadline6-dev

然后,问题就解决了。

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