简体   繁体   English

为什么我在 CentOS 7 上编译 Ruby 3.2 时出错?

[英]Why do I get error compiling Ruby 3.2 on CentOS 7?

I try to build Ruby 3.2 using ruby-build plugin for rbenv but get some strange compilation error:我尝试使用 rbenv 的 ruby-build 插件构建 Ruby 3.2,但出现了一些奇怪的编译错误:

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 .这是完整的日志: https://gist.github.com/tycooon/c077a1d99299469bd86131211c565ff7

Ruby 3.1 builds without any problems on the same machine. Ruby 3.1 在同一台机器上构建没有任何问题。 What could be the problem?可能是什么问题呢?

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:问题是 centos7 附带太旧的 GCC。在我的机器上有devtoolset-7-gcc.x86_64 package 可用,所以我能够使用以下命令安装 Ruby 3.2:

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

Hope this helps someone.希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM