To view your current version of GCC, you can use the command:
yum info gcc
[root@tutorialspots.com ~]# yum info gcc Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.lstn.net * epel: fedora-epel.mirror.lstn.net * extras: yum.tamu.edu * updates: pubmirrors.dal.corespace.com Installed Packages Name : gcc Arch : x86_64 Version : 4.4.7 Release : 16.el6 Size : 19 M Repo : installed From repo : base Summary : Various compilers (C, C++, Objective-C, Java, ...) URL : http://gcc.gnu.org License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions Description : The gcc package contains the GNU Compiler Collection version 4.4. : You'll need this package in order to compile C code.
or use the command
gcc --version
Result:
[root@tutorialspots.com ~]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) 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@downappz ~]# cat /etc/*release* CentOS release 6.5 (Final) CentOS release 6.5 (Final) CentOS release 6.5 (Final) cpe:/o:centos:linux:6:GA
You try to upgrade GCC but unsuccessfully.
[root@tutorialspots.com ~]# yum upgrade gcc Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.lstn.net * epel: fedora-epel.mirror.lstn.net * extras: yum.tamu.edu * updates: pubmirrors.dal.corespace.com Setting up Upgrade Process No Packages marked for Update
How to upgrade GCC on Linux?
Method 1: Install redhat developer toolset 1.1
Step 1: Download file devtools-1.1.repo to your server.
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -O /etc/yum.repos.d/devtools-1.1.repo
Result:
[root@downappz ~]# wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.r epo -O /etc/yum.repos.d/devtools-1.1.repo --2015-09-23 09:01:56-- http://people.centos.org/tru/devtools-1.1/devtools-1.1. repo Resolving people.centos.org... 204.15.73.242 Connecting to people.centos.org|204.15.73.242|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 174 1 Saving to: `/etc/yum.repos.d/devtools-1.1.repo' 100%[======================================>] 174 --.-K/s in 0s 2015-09-23 09:01:56 (18.0 MB/s) - `/etc/yum.repos.d/devtools-1.1.repo' saved [17 4/174]
Step 2: use yum to install redhat developer toolset 1.1
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
[root@tutorialspots.com ~]# yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1. 1-gcc devtoolset-1.1-gcc-c++ Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.lstn.net * epel: fedora-epel.mirror.lstn.net * extras: yum.tamu.edu * updates: pubmirrors.dal.corespace.com testing-1.1-devtools-6 | 951 B 00:00 testing-1.1-devtools-6/primary | 13 kB 00:00 testing-1.1-devtools-6 42/42 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package devtoolset-1.1-gcc.x86_64 0:4.7.2-5.el6 will be installed --> Processing Dependency: devtoolset-1.1-runtime for package: devtoolset-1.1-gc c-4.7.2-5.el6.x86_64 ---> Package devtoolset-1.1-gcc-c++.x86_64 0:4.7.2-5.el6 will be installed --> Processing Dependency: devtoolset-1.1-libstdc++-devel = 4.7.2-5.el6 for pack age: devtoolset-1.1-gcc-c++-4.7.2-5.el6.x86_64 --> Running transaction check ---> Package devtoolset-1.1-libstdc++-devel.x86_64 0:4.7.2-5.el6 will be install ed base/filelists_db | 6.3 MB 00:00 http://fedora-epel.mirror.lstn.net/6/x86_64/repodata/4264baf3a86a37d82110fd30ec9 43ab2c028640b443a00359a9f56c31424c37e-filelists.sqlite.bz2: [Errno 14] PYCURL ER ROR 22 - "The requested URL returned error: 404 Not Found" Trying other mirror. epel/filelists_db | 8.2 MB 00:00 extras/filelists_db | 36 kB 00:00 nginx/filelists_db | 4.7 kB 00:00 testing-1.1-devtools-6/filelists | 109 kB 00:00 updates/filelists_db | 1.6 MB 00:00 vesta/filelists_db | 48 kB 00:00 vz-base/filelists | 824 B 00:00 vz-updates/filelists | 3.0 kB 00:00 ---> Package devtoolset-1.1-runtime.noarch 0:1-13.el6 will be installed --> Processing Dependency: scl-utils for package: devtoolset-1.1-runtime-1-13.el 6.noarch --> Running transaction check ---> Package scl-utils.x86_64 0:20120927-27.el6_6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: devtoolset-1.1-gcc x86_64 4.7.2-5.el6 testing-1.1-devtools-6 19 M devtoolset-1.1-gcc-c++ x86_64 4.7.2-5.el6 testing-1.1-devtools-6 6.1 M Installing for dependencies: devtoolset-1.1-libstdc++-devel x86_64 4.7.2-5.el6 testing-1.1-devtools-6 1.8 M devtoolset-1.1-runtime noarch 1-13.el6 testing-1.1-devtools-6 1.0 M scl-utils x86_64 20120927-27.el6_6 base 22 k Transaction Summary ================================================================================ Install 5 Package(s) Total download size: 28 M Installed size: 62 M Is this ok [y/N]: y Downloading Packages: (1/5): devtoolset-1.1-gcc-4.7.2-5.el6.x86_64.rpm | 19 MB 00:02 (2/5): devtoolset-1.1-gcc-c++-4.7.2-5.el6.x86_64.rpm | 6.1 MB 00:00 (3/5): devtoolset-1.1-libstdc++-devel-4.7.2-5.el6.x86_64 | 1.8 MB 00:00 (4/5): devtoolset-1.1-runtime-1-13.el6.noarch.rpm | 1.0 MB 00:00 (5/5): scl-utils-20120927-27.el6_6.x86_64.rpm | 22 kB 00:00 -------------------------------------------------------------------------------- Total 6.4 MB/s | 28 MB 00:04 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : scl-utils-20120927-27.el6_6.x86_64 1/5 Installing : devtoolset-1.1-runtime-1-13.el6.noarch 2/5 Installing : devtoolset-1.1-gcc-4.7.2-5.el6.x86_64 3/5 Installing : devtoolset-1.1-libstdc++-devel-4.7.2-5.el6.x86_64 4/5 Installing : devtoolset-1.1-gcc-c++-4.7.2-5.el6.x86_64 5/5 Verifying : devtoolset-1.1-gcc-4.7.2-5.el6.x86_64 1/5 Verifying : devtoolset-1.1-libstdc++-devel-4.7.2-5.el6.x86_64 2/5 Verifying : scl-utils-20120927-27.el6_6.x86_64 3/5 Verifying : devtoolset-1.1-runtime-1-13.el6.noarch 4/5 Verifying : devtoolset-1.1-gcc-c++-4.7.2-5.el6.x86_64 5/5 Installed: devtoolset-1.1-gcc.x86_64 0:4.7.2-5.el6 devtoolset-1.1-gcc-c++.x86_64 0:4.7.2-5.el6 Dependency Installed: devtoolset-1.1-libstdc++-devel.x86_64 0:4.7.2-5.el6 devtoolset-1.1-runtime.noarch 0:1-13.el6 scl-utils.x86_64 0:20120927-27.el6_6 Complete!
You can find GCC in directory /opt/centos/devtoolset-1.1/root/usr/bin.
Step 3: create backup of GCC
mv /usr/bin/gcc /usr/bin/gcc.bckup
Step 4: create symbolic link from /opt/centos/devtoolset-1.1/root/usr/bin/gcc to /usr/bin/gcc
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc /usr/bin/gcc