如何在CentOS 7中安装GCC编译器?

GCC(GNU编译器集合的简称)是一组编程编译器的集合,包括C,C ++,Objective-C,Fortran,Java和Ada。GCC是GNU工具链的关键组件,也是大多数类Unix操作系统的标准编译器。自由软件基金会根据GNU通用公共许可证发行GCC。

在下面的教程中,我们将在CentOS 7上执行GCC安装。安装过程非常简单,并且不会超过10分钟。

步骤1:在服务器上执行更新

注意:您需要以root用户身份通过​​SSH登录到CentOS 7 VPS。

#ssh root@IP_Address -p Port_number

要更新服务器上所有已安装的软件包,可以使用以下命令

#yum -y update

步骤2:从存储库安装GCC

可以从官方CentOS资料库轻松安装GCC。运行以下命令以在服务器上安装GCC

#yum -y install gcc

输出:

Running transaction test
Transaction test succeeded
Running transaction
Installing : cpp-4.8.5-36.el7.x86_64                                                                                                            1/5
Installing : kernel-headers-3.10.0-957.5.1.el7.x86_64                                                                                           2/5
Installing : glibc-headers-2.17-260.el7_6.3.x86_64                                                                                              3/5
Installing : glibc-devel-2.17-260.el7_6.3.x86_64                                                                                                4/5
Installing : gcc-4.8.5-36.el7.x86_64                                                                                                            5/5
Verifying  : glibc-devel-2.17-260.el7_6.3.x86_64                                                                                                1/5
Verifying  : gcc-4.8.5-36.el7.x86_64                                                                                                            2/5
Verifying  : kernel-headers-3.10.0-957.5.1.el7.x86_64                                                                                           3/5
Verifying  : cpp-4.8.5-36.el7.x86_64                                                                                                            4/5
Verifying  : glibc-headers-2.17-260.el7_6.3.x86_64                                                                                              5/5

Installed:
gcc.x86_64 0:4.8.5-36.el7                                                                                                                       

Dependency Installed:
cpp.x86_64 0:4.8.5-36.el7 glibc-devel.x86_64 0:2.17-260.el7_6.3 glibc-headers.x86_64 0:2.17-260.el7_6.3 kernel-headers.x86_64 0:3.10.0-957.5.1.el7
Complete!

步骤3:在CentOS 7上验证GCC安装

编译过程完成后。您可以检查是否已正确安装GCC。

gcc --version

输出:

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 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.

More Articles & Posts