Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an RHEL 6 server with gcc version 4.4.7. I wanted to update the gcc version (I think the current one is 4.8). Yum update doesn't work. Also, SO answers for a similar question on CentOS does not work. I followed the methods in the accepted answer, the output is "Error getting repository data for testing-1.1-devtools-6, repository not found". Also I am not sure whether I should follow the methods for CentOs.

Has anyone updated gcc in RHEL 6 x86_64 server?

share|improve this question
    
Did you try to install it from this repo? hop5.in/yum/el6/repoview/gcc.html. These are binary builds of 4.8.2. You'll likely need to be at 6.4 CentOS to install them, which might be your issue. – slm Apr 20 '14 at 1:37
    
Is installing from source an option? – Ketan Apr 20 '14 at 1:37
    
yes i can install from source if needed. – rivu Apr 21 '14 at 23:38
    
good question. Who's the downvoter? :( – Otheus Feb 23 at 15:08
    
hop5.in is no longer a valid el6 repo of anything, apparently. @slm – Otheus Feb 23 at 15:10
up vote 0 down vote accepted

The easiest method by far is to make use of a binary build that's provided through a YUM repository. One such option would be to use the hop5.in repository. Specifically this page: gcc - Various compilers (C, C++, Objective-C, Java, ...). They're providing 4.8.2 which should work with CentOS 6.3 or 6.4. You might want to do an update prior:

$ sudo yum update

The other option would be to make use of the Developer Toolset, specifically the bundled version provided by Scientific Linux.

Following the installation instructions you'll basically do the following 2 steps:

add repositories
$ sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo \
    http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
$ wget -O /etc/yum.repos.d/slc5-devtoolset.repo \
    http://linuxsoft.cern.ch/cern/devtoolset/slc5-devtoolset.repo
install devtoolset
$ sudo yum install devtoolset-2

Update #1

The hop5.in YUM repository appears to have been removed, so the only recourse is to make use of the devtoolset method highlighted above.

Additional examples for installing via devtoolset are highlighted in this GitHub Gist: Installing gcc 4.8 and Linuxbrew on CentOS 6.

share|improve this answer
3  
I tried to install the rpm downloaded from the first link, says "error: Failed dependencies: cpp = 4.8.2-8.el6 is needed by gcc-4.8.2-8.el6.x86_64 ...". For the developer toolset, it says "people.centos.org/tru/devtools-1.1/6Server/x86_64/RPMS/repodata/…: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found". I think the problem is it is 6Server instead of 6 in the link. I don't know how to fix that. – rivu Apr 21 '14 at 23:38
    
hop.in no longer has what I think you think it has. – Otheus Feb 23 at 15:16
    
Additional step possibly needed: Downloading and importing cern key from http://ftp.scientificlinux.org/linux/scientific/5x/x86_64/RPM-GPG-KEYs/RPM-GPG-‌​KEY-cern. I love that the site doesn't have https. Way to go scilinux. After you download it (tmp directory or whever), import it with rpm --import RPM-GPG-KEY-cern and then do yum install. – Otheus Feb 23 at 15:21
    
@Otheus - thanks, I hate when repos bite the dust like this, wrecks a bunch of content on the interwebs 8-). – slm Feb 23 at 20:13

Red Hat Software Collections comes with GCC 4.9 you may look at enabling that channel.

share|improve this answer

I've built newer gcc versions for rhel6 for several versions now (since 4.7.x to 5.3.1).

The process is fairly easy thanks to Redhat's Jakub Jelinek fedora gcc builds found on koji

Simply grab the latest src rpm for whichever version you require (e.g. 5.3.1).

Basically you would start by determining the build requirements by issuing rpm -qpR src.rpm looking for any version requirements:

rpm -qpR gcc-5.3.1-4.fc23.src.rpm | grep -E '= [[:digit:]]'
binutils >= 2.24
doxygen >= 1.7.1
elfutils-devel >= 0.147
elfutils-libelf-devel >= 0.147
gcc-gnat >= 3.1
glibc-devel >= 2.4.90-13
gmp-devel >= 4.1.2-8
isl = 0.14
isl-devel = 0.14
libgnat >= 3.1
libmpc-devel >= 0.8.1
mpfr-devel >= 2.2.1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
systemtap-sdt-devel >= 1.3

Now comes the tedious part - any package which has a version higher than provided by yum fro your distro needs to be downloaded from koji, and recursively repeat the process until all dependency requirements are met.

I cheat, btw.
I usually repackage the rpm to contain a correct build tree using the gnu facility to use correctly placed and named requirements, so gmp/mpc/mpfr/isl (cloog is no longer required) are downloaded and untard into the correct path, and the new (bloated) tar is rebuilt into a new src rpm (with minor changes to spec file) with no dependency on their packaged (rpm) versions. Since I know of no one using ADA, I simply remove the portions pertaining to gnat from the specfile, further simplifying the build process, leaving me with just binutils to worry about.
Gcc can actually build with older binutils, so if you're in a hurry, further edit the specfile to require the binutils version already present on your system. This will result in a slightly crippled gcc, but mostly it will perform well enough.
This works quite well mostly.

UPDATE 1

The simplest method for opening a src rpm is probably yum install the rpm and access everything under ~/rpmbuild, but I prefer

mkdir gcc-5.3.1-4.fc23
cd gcc-5.3.1-4.fc23
rpm2cpio ../gcc-5.3.1-4.fc23.src.rpm | cpio -id
tar xf gcc-5.3.1-20160212.tar.bz2
cd gcc-5.3.1-20160212
contrib/download_prerequisites
cd ..
tar caf gcc-5.3.1-20160212.tar.bz2 gcc-5.3.1-20160212
rm -rf gcc-5.3.1-20160212
# remove gnat
sed -i '/%global build_ada 1/ s/1/0/' gcc.spec
sed -i '/%if !%{build_ada}/,/%endif/ s/^/#/' gcc.spec
# remove gmp/mpfr/mpc dependencies
sed -i '/BuildRequires: gmp-devel >= 4.1.2-8, mpfr-devel >= 2.2.1, libmpc-devel >= 0.8.1/ s/.*//' gcc.spec
# remove isl dependency
sed -i '/BuildRequires: isl = %{isl_version}/,/Requires: isl = %{isl_version}/ s/^/#/' gcc.spec
# Either build binutils as I do, or lower requirements
sed -i '/Requires: binutils/ s/2.24/2.20/' gcc.spec
# Make sure you don't break on gcc-java
sed -i '/gcc-java/ s/^/#/' gcc.spec

You also have the choice to set prefix so this rpm will install side-by-side without breaking distro rpm (but requires changing name, and some modifications to internal package names). I usually add an environment-module so I can load and unload this gcc as required (similar to how collections work) as part of the rpm (so I add a new dependency).

Finally create the rpmbuild tree and place the files where hey should go and build:

yum install rpmdevtools rpm-build
rpmdev-setuptree
cp * ~/rpmbuild/SOURCES/
mv ~/rpmbuild/{SOURCES,SPECS}/gcc.spec
rpmbuild -ba ~/rpmbuild/SPECS/gcc.spec

UPDATE 2

Normally one should not use a "server" os for development - that's why you have fedora which already comes with latest gcc. I have some particular requirements, but you should really consider using the right tool for the task - rhel/centos to run production apps, fedora to develop those apps etc.

share|improve this answer
    
It's polite when down-voting to give a reason. – Dani_l Feb 23 at 22:30

you can attempt gcc source buid.GCC requires MPC , MPFR and GMP as pre requisites.For GCC 4.8 , The version dependencies are MPC 0.8 GMP 6.0 MPFR 2.4.2.Down load the source packages , and install all packages under /usr/lib.The order of installation is gmp,mpfr,mpc

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.