centos 6.6 安装 gcc 4.9.1

时间:2022-08-11 02:20:14

不用编译,执行下面三步即可

cd /etc/yum.repos.d
wget http://linuxsoft.cern.ch/cern/scl/slc6-scl.repo
yum -y --nogpgcheck install devtoolset-3-gcc devtoolset-3-gcc-c++

安装到了以下目录

/opt/rh/devtoolset-3/root/usr/bin

现在建立修改原来的gcc到现在的gcc

[root@10-149-11-152 bin]# pwd
/opt/rh/devtoolset-3/root/usr/bin
[root@10-149-11-152 bin]# cd /usr/bin/
[root@10-149-11-152 bin]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
Copyright (C) 2010 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@10-149-11-152 bin]# cp gcc gcc-4.4.7
[root@10-149-11-152 bin]# c++ --version
c++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
Copyright (C) 2010 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@10-149-11-152 bin]# cp c++ c++-4.4.7
[root@10-149-11-152 bin]# rm gcc
rm: remove regular file `gcc'? y
[root@10-149-11-152 bin]# rm c++
rm: remove regular file `c++'? y
[root@10-149-11-152 bin]# ln -s /opt/rh/devtoolset-3/root/usr/bin/gcc /usr/bin/gcc
[root@10-149-11-152 bin]# ln -s /opt/rh/devtoolset-3/root/usr/bin/c++ /usr/bin/c++
[root@10-149-11-152 bin]# gcc --version
gcc (GCC) 4.9.1 20140922 (Red Hat 4.9.1-10)
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@10-149-11-152 bin]# c++ --version
c++ (GCC) 4.9.1 20140922 (Red Hat 4.9.1-10)
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.