如果服务器是自己的,并且机器就在身边,那什么都不用说了,缺少gcc顶多就是重新放入安装盘,把开发工具包安装上。但是如果是租的服务器,托管服务 方那帮人又搞不懂你说的啥子gcc,要安装gcc实在是太麻烦了。你得去找gcc相关的包,版本号还得必须对应上,否则不兼容。最近给一个朋友装gcc, 着实头疼了一把。后来发现yum这个好东西,只需要执行一个命令,所有的烦恼都解除了。
朋友的系统是CentOS 5 的,托管商没给安装gcc,于是使用如下两个命令就可把gcc,gcc-c++统统安装上:
yum -y install gcc
yum -y install gcc-c++
yum会自动查找软件的相关依赖包,自动下载安装,全过程轻松愉快。特此记录一下。
[root@localhost ~]# yum -y install gcc
Loaded plugins: fastestmirror, rhnplugin, security
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
This system is not registered with RHN.
RHN support will be disabled.
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-51.el5 set to be updated
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package glibc-devel.i386 0:2.5-65 set to be updated
--> Processing Dependency: glibc-headers = 2.5-65 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Running transaction check
---> Package glibc-headers.i386 0:2.5-65 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.i386 0:2.6.18-274.3.1.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc i386 4.1.2-51.el5 base 5.2 M
Installing for dependencies:
glibc-devel i386 2.5-65 base 2.0 M
glibc-headers i386 2.5-65 base 604 k
kernel-headers i386 2.6.18-274.3.1.el5 updates 1.2 M
Transaction Summary
================================================================================
Install 4 Package(s)
Upgrade 0 Package(s)
Total download size: 9.1 M
Downloading Packages:
(1/4): glibc-headers-2.5-65.i386.rpm | 604 kB 00:06
(2/4): kernel-headers-2.6.18-274.3.1.el5.i386.rpm | 1.2 MB 00:14
(3/4): glibc-devel-2.5-65.i386.rpm | 2.0 MB 00:11
(4/4): gcc-4.1.2-51.el5.i386.rpm | 5.2 MB 00:27
--------------------------------------------------------------------------------
Total 149 kB/s | 9.1 MB 01:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : kernel-headers 1/4
Installing : glibc-headers 2/4
Installing : glibc-devel 3/4
Installing : gcc 4/4
Installed:
gcc.i386 0:4.1.2-51.el5
Dependency Installed:
glibc-devel.i386 0:2.5-65 glibc-headers.i386 0:2.5-65
kernel-headers.i386 0:2.6.18-274.3.1.el5
Complete!
[root@localhost ~]#
[root@localhost ~]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-51.el5 set to be updated
--> Processing Dependency: cpp = 4.1.2-51.el5 for package: gcc
--> Processing Dependency: libgomp >= 4.1.2-51.el5 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Processing Dependency: libgcc >= 4.1.2-51.el5 for package: gcc
--> Running transaction check
---> Package cpp.i386 0:4.1.2-51.el5 set to be updated
---> Package glibc-devel.i386 0:2.5-65 set to be updated
--> Processing Dependency: glibc-headers = 2.5-65 for package: glibc-devel
--> Processing Dependency: glibc = 2.5-65 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
---> Package libgcc.i386 0:4.1.2-51.el5 set to be updated
---> Package libgomp.i386 0:4.4.4-13.el5 set to be updated
--> Running transaction check
--> Processing Dependency: glibc = 2.5-49 for package: nscd
---> Package glibc.i686 0:2.5-65 set to be updated
--> Processing Dependency: glibc-common = 2.5-65 for package: glibc
---> Package glibc-headers.i386 0:2.5-65 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package glibc-common.i386 0:2.5-65 set to be updated
---> Package kernel-headers.i386 0:2.6.18-274.el5 set to be updated
---> Package nscd.i386 0:2.5-65 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc i386 4.1.2-51.el5 base 5.2 M
Installing for dependencies:
glibc-devel i386 2.5-65 base 2.0 M
glibc-headers i386 2.5-65 base 604 k
kernel-headers i386 2.6.18-274.el5 base 1.2 M
libgomp i386 4.4.4-13.el5 base 72 k
Updating for dependencies:
cpp i386 4.1.2-51.el5 base 2.7 M
glibc i686 2.5-65 base 5.3 M
glibc-common i386 2.5-65 base 16 M
libgcc i386 4.1.2-51.el5 base 96 k
nscd i386 2.5-65 base 169 k
Transaction Summary
================================================================================
Install 5 Package(s)
Upgrade 5 Package(s)
Total download size: 34 M
Is this ok [y/N]: y
Downloading Packages: