gcc很好安装,直接输入命令:yum install gcc 即可。
检查一下是否安装成功:
[root@master protobuf-2.5.0]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
出现以上信息说明gcc安装成功。
安装g++,如果直接输入:yum install g++,则会出现
[root@master protobuf-2.5.0]# yum install g++
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
No package g++ available.
Error: Nothing to do
原因是在centos下g++安装包名字叫做:gcc-c++
所以应该输入 yum install gcc-c++,即可。
[root@master protobuf-2.5.0]# yum install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64
--> Processing Dependency: libstdc++ = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.4.7-18.el6 will be updated
---> Package libstdc++.x86_64 0:4.4.7-23.el6 will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-23.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc-c++ x86_64 4.4.7-23.el6 base 4.7 M
Installing for dependencies:
libstdc++-devel x86_64 4.4.7-23.el6 base 1.6 M
Updating for dependencies:
libstdc++ x86_64 4.4.7-23.el6 base 296 k
Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 1 Package(s)
Total download size: 6.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): gcc-c++-4.4.7-23.el6.x86_64.rpm | 4.7 MB 00:01
(2/3): libstdc++-4.4.7-23.el6.x86_64.rpm | 296 kB 00:00
(3/3): libstdc++-devel-4.4.7-23.el6.x86_64.rpm | 1.6 MB 00:00
--------------------------------------------------------------------------------
Total 2.5 MB/s | 6.6 MB 00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libstdc++-4.4.7-23.el6.x86_64 1/4
Installing : libstdc++-devel-4.4.7-23.el6.x86_64 2/4
Installing : gcc-c++-4.4.7-23.el6.x86_64 3/4
Cleanup : libstdc++-4.4.7-18.el6.x86_64 4/4
Verifying : libstdc++-4.4.7-23.el6.x86_64 1/4
Verifying : libstdc++-devel-4.4.7-23.el6.x86_64 2/4
Verifying : gcc-c++-4.4.7-23.el6.x86_64 3/4
Verifying : libstdc++-4.4.7-18.el6.x86_64 4/4
Installed:
gcc-c++.x86_64 0:4.4.7-23.el6
Dependency Installed:
libstdc++-devel.x86_64 0:4.4.7-23.el6
Dependency Updated:
libstdc++.x86_64 0:4.4.7-23.el6
Complete!
查看一下版本信息
[root@master protobuf-2.5.0]# g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
安装成功!