CentOS下使用YUM安装GCC、gcc-c++
2017-11-19
999
在安装服务器的时候图快捷没有装一些系统软件,结果后来需要使用C++编译环境,由于系统本身没有C编译环境,所以不能下载源码进行安装,只能下载rpm文件进行安装,可是在使用rpm安装时,有许多的依赖安装包,又考虑到系统可以联网所以便使用了YUM安装GCC。
先说下YUM的原理吧:CentOS先将发布的软件放置到YUM服务器内,然后分析这些软件的依赖属性,将软件内的记录信息写下来。然后将这些信息分析后记录成软件相关性的清单列表。当客户端有软件安装的需求时,客户端主机会主动想网络上面的yum服务器请求下载要安装的软件和相关的依赖性属性的软件。
说了这么多直接上这两句高端大气上档次的语句吧:
yum -y install gcc
yum -y install gcc-c++
下图显示安装的过程:
[cpp] view plain
copy
- [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 ~]#