compile Ruby 2.0 errors without rvm or rbenv , `readline.c:1886:26: error: 'Function' undeclared (first use in this function)`

戏子无情 提交于 2019-11-27 01:57:42

问题


I want to install gitlab, which don't recommend to use any ruby version manager. But

This is my OS 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

回答1:


I also have Ubuntu 14.04 and I got to make it work. Sharing what I did just in case it works for you.

I patched the file ext/readline/readline.c replacing line 1886:

rl_pre_input_hook = (Function *)readline_pre_input_hook;

With

rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;

Then I tried to make it again and it worked.

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




回答2:


I also ran into this issue trying to install ruby-2.0.0-p247 with rbenv. Save some time by using this patch.

You can run it like this:

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



回答3:


This is my solution on Ubuntu 14.04 Server edition.

I need to install underline

sudo apt-get install libreadline6 libreadline6-dev

Then, the problem was fixed.




回答4:


Found a solution from https://github.com/sstephenson/ruby-build/issues/690. What actually missing is libffi-dev. I tried on Ubuntu 12.04 and it is successful.

sudo apt-get install libffi-dev


来源:https://stackoverflow.com/questions/23488790/compile-ruby-2-0-errors-without-rvm-or-rbenv-readline-c188626-error-func

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!