CentOS 6 升级 gcc 和 g++ 的方法

CentOS 6 系统自带的 gcc 或者 g++ 的版本是:g++ (GCC) 4.4.6. GCC 版本太旧,导致了很多使用上的不便,如:无法使用g++ -std=c++11 命令来编译 C++11、无法使用Vim的很多插件(YouCompleteMe等)。因此,有必要对它进行升级

对 GCC 升级无法直接使用:

yum update gcc

以下是升级的详细过程。

1.使用 redhat developer toolset 1.1 的repo,安装GCC

cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

2. 替换系统中原来的GCC

通过第一步会把 GCC 安装到以下目录:

/opt/centos/devtoolset-1.1/root/usr/bin/

接下来需要修改系统的配置,使认的 gcc 和 g++ 命令使用的是新安装的版本。

ln -s /opt/centos/devtoolset-1.1/root/usr/bin/* /usr/local/bin/ hash -r

现在查看 g++ 的版本号:

g++ --version g++ (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5) copyright (C) 2012 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.

已经从4.4.6升级到4.7.2了。


Reference

http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos/542091#542091

(原文链接http://www.wengweitao.com/centos-sheng-ji-gcc-he-g-de-fang-fa.html)

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native