Home > Mobile >  Why do I get error compiling Ruby 3.2 on CentOS 7?
Why do I get error compiling Ruby 3.2 on CentOS 7?

Time:01-16

I try to build Ruby 3.2 using ruby-build plugin for rbenv but get some strange compilation error:

compiling bignum.c
In file included from vm_core.h:164:0,
                 from iseq.h:14,
                 from mini_builtin.c:3,
                 from miniinit.c:51:
thread_pthread.h:109:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
 RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
                                       ^
In file included from iseq.h:14:0,
                 from mini_builtin.c:3,
                 from miniinit.c:51:
vm_core.h: In function ‘rb_current_execution_context’:
vm_core.h:1864:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
     rb_execution_context_t *ec = ruby_current_ec;
                                  ^
vm_core.h:1864:34: note: each undeclared identifier is reported only once for each function it appears in

Here is the full log: https://gist.github.com/tycooon/c077a1d99299469bd86131211c565ff7.

Ruby 3.1 builds without any problems on the same machine. What could be the problem?

CodePudding user response:

The problem was centos7 being shipped with too old GCC. There was devtoolset-7-gcc.x86_64 package available on the machine in my case, so I was able to install Ruby 3.2 using the following command:

CC=/opt/rh/devtoolset-7/root/usr/bin/gcc rbenv install 3.2.0 -v

Hope this helps someone.

  • Related