4
[root@localhost dyliu]# yum list gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.mirrors.tds.net
 * extras: centos.mirrors.tds.net
 * rpmforge: apt.sw.be
 * updates: mirror.ubiquityservers.com
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

2 Answers 2

0

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 gcc.gnu.org

0

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, http://www.mpfr.org/), gmp (5.1.2, http://gmplib.org/) and mpc (1.0.1, http://www.multiprecision.org/) 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.

You must log in to answer this question.

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