Press "Enter" to skip to content

解决Red Hat系统”Cannot find a C compiler, aborting”问题

前日在某Red Hat系统安装软件的时候,突然提示“Cannot find a C compiler, aborting”。这是因为缺少gcc编译器导致的。gcc编译器是将源代码处理为机器可认识的二进制文件的重要程序。换言之,如果没有gcc编译器,就不能通过源代码方式来安装程序。一般的系统默认都会安装之,但也有少量系统未安装。

[root@localhost axel-2.4]# ./configure --prefix=/usr/local/axel
Cannot find a C compiler, aborting.
[root@localhost axel-2.4]# gcc --version     //查看gcc版本
bash: gcc: command not found

我们可以自己下载gcc软件包安装,但因为gcc有大量的依赖包,因此推荐使用yum方式来安装。

1,如果系统能连网,直接执行”yum install gcc*”安装gcc即可

2,如果系统不能连网,Red Hat安装光盘里自带了gcc软件包及其相关依赖包,我们只要将本地光盘设置为yum更新源,然后再执行”yum install gcc*”即可。

安装完成以后的检测:

[root@localhost axel-2.4]# gcc --version         //查看c编译器的版本
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@localhost axel-2.4]# g++ --version        //查看c++编译器的版本
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Leave a Reply

Your email address will not be published. Required fields are marked *