Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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
[root@localhost dyliu]# yum list gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * rpmforge:
 * updates:
Installed Packages
gcc.i686                    4.4.6-3.el6                    @anaconda-CentOS-201112130233.i386/6.2

By default, if I run yum install gcc, the yum tool will install gcc 4.4.6 for me.

Question> How to install the latest gcc 4.7.0 on centos 6.2?

Thank you

share|improve this question

If you can't find any official or unofficial RPMs for CentOS 6.2 you could try an RPM intended for other systems that are reasonably similar such as Fedora. This will not always work because the versions of shared libraries (run-time dependencies) for the target system will not necessarily correspond with the ones on your system.

Building your own binaries is also an option. To do that you'll have to install the dependencies, run the configuration scripts and the automated compilation process and finally move the binaries to the /bin and /usr/lib folders of your system.

The downside is the uninstall process is messy, unless you keep track of what is installed or retain the source folder (so make uninstall is available).

Manual compilation of gcc is outlined on

share|improve this answer

Compiling gcc yourself is definitely an option. It is not too hard; I managed to compile gcc 4.8.1 on RHEL 5.9 following the link Ярослав Рахматуллин mentioned. I had to download mpfr (3.1.2,, gmp (5.1.2, and mpc (1.0.1, as dependencies.

Especially useful tips derived from the Manual Compilation document: * unpack the mpfr, gmp and mpc sources into your gcc source directory and link them like this: ln -s mpfr-3.1.2 mpfr ; ln -s gmp-5.1.2 gmp ; ln -s mpc-1.0.1 mpc. * use out-of-source building (e.g. on the same level as your gcc-4.8.1 source dir resides: mkdir gcc-build ; cd gcc-build ; ../gcc-4.8.1/configure --prefix=/home/user/usr)

The actual compilation of the whole compiler collection took ages even though I used 10 processors for parallel building.

As suggested by Ярослав Рахматуллин, in case your installation directory (prefix) already contains other compiled programs, you might want to "record" the contents of it before and after doing 'make install' doing something like this:

'find /home/user/usr > state.before ; make install ; find /home/user/usr > state.after'

so you could compare the two files and delete the differences, should it ever be necessary to remove the new gcc (I must note though, that I personally have not tried this method, but rather keep the build directory to be able to do 'make uninstall').

Be sure to adjust your PATH variable to include /home/user/usr/bin.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .