Question

I am currently using CentOS 5.8 and I would like to update g++ to the most recent version. My current version of g++ is 4.1.2, and when I try to update it says I am already on the latest version.

Is there a way to force update to the current version?

Was it helpful?

Solution

The RHEL (and CentOS) 5.x series use GCC 4.1 and do not provide newer versions because they are stable, "enterprise" distributions so you can't update to a newer version using yum.

(If you want a newer system compiler then don't use such an old "Enterprise" distribution, either use CentOS 6 or a non-enterprise distro such as Fedora).

It's easy to install a newer GCC elsewhere on the system and then use that instead. Just download the gcc-4.9.0.tar.gz file from a GNU mirror and read Installing GCC for simple instructions on building it. It is a bad idea to overwrite the existing system compiler, you should install to /usr/local or /opt or another directory. You can then alter your $PATH so the newer GCC will be used. You should also read about setting dynamic library paths in the libstdc++ FAQ.

Another alternative is to install the Developer Toolset, which is an optional add-on providing a recent version of GCC and other dev tools, see http://linux.web.cern.ch/linux/devtoolset/ for a re-packaged version for Scientific Linux that should be compatible with CentOS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top