centos7.2 gcc 升級4.9 5.2

本文详细介绍了如何在CentOS系统上安装多个版本的GCC编译器,包括4.8、4.9及5.2版本,并展示了如何通过修改~/.bashrc文件来切换不同版本的GCC。

gcc 4.8 安装

 

[root@DS-VM-Node239 ~]# curl -Lks http://www.hop5.in/yum/el6/hop5.repo > /etc/yum.repos.d/hop5.repo

[root@DS-VM-Node239 ~]# yum install gcc gcc-g++ -y

[root@DS-VM-Node239 ~]# gcc --version

gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-8)

Copyright © 2013 Free Software Foundation, Inc.

本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;

包括没有适销性和某一专用目的下的适用性担保。

[root@DS-VM-Node239 ~]# g++ --version

g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-8)

Copyright © 2013 Free Software Foundation, Inc.

本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;

包括没有适销性和某一专用目的下的适用性担保。

[root@DS-VM-Node211 ~]#

gcc 4.9 安装

 

[root@DS-VM-Node239 ~]# yum install centos-release-scl -y

[root@DS-VM-Node239 ~]# yum install devtoolset-3-toolchain -y

[root@DS-VM-Node239 ~]# scl enable devtoolset-3 bash

[root@DS-VM-Node239 ~]# gcc --version

gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

Copyright (C) 2014 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.

 

[root@DS-VM-Node239 ~]# g++ --version

g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

Copyright (C) 2014 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.

 

[root@DS-VM-Node239 ~]# gfortran --version

GNU Fortran (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

Copyright (C) 2014 Free Software Foundation, Inc.

 

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.

You may redistribute copies of GNU Fortran

under the terms of the GNU General Public License.

For more information about these matters, see the file named COPYING

 

[root@DS-VM-Node239 ~]#

gcc 5.2 安装

 

[root@DS-VM-Node239 ~]# yum install centos-release-scl -y

[root@DS-VM-Node239 ~]# yum install devtoolset-4-toolchain -y

[root@DS-VM-Node239 ~]# scl enable devtoolset-4 bash

[root@DS-VM-Node239 ~]# gcc --version

gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)

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.

 

[root@DS-VM-Node239 ~]# g++ --version

g++ (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)

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.

 

[root@DS-VM-Node239 ~]#

 

 

 

在~/.bashrc 中添加相應的path 

source /opt/rh/devtoolset-{x}/enable

/opt/rh/devtoolset-3/root/usr/bin/:$PATH

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值