How to install GCC 4.7 on the CentOS 6

Description: Storage for Sources, File Format Descriptions, Objects tables, algorithms, schemes, etc. (Answering only)
Moderator: Moderators

Wohlstand M
Topic author, Lead Developer
Lead Developer
Avatar
Wohlstand M
Topic author, Lead Developer
Lead Developer
Age: 25
Reputation: 321
Posts: 1302
Joined: 15 Feb 2014
Location: Moscow, Russia
Website Skype YouTube

Post #1by Wohlstand » 14 Sep 2014, 13:37

http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos

Tru Huynh of centos.org has built the redhat developer toolset 1.1, for centos and it contains gcc 4.7.2

So you could simply use his repo and install just gcc, instantly.

Code: Select all

cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

This will install it most likely into /opt/centos/devtoolset-1.1/root/usr/bin/
Then you can tell your compile process to use the gcc 4.7 instead of 4.4 with the CC variable

Code: Select all

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc 
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++



And last thing:
Replace your installed gcc to your symlinks, and you will have the gcc 4.7 to allow of C++11 standard ;-)

Code: Select all

mv /usr/bin/gcc /usr/bin/gcc_old
mv /usr/bin/cpp /usr/bin/cpp_old
mv /usr/bin/c++ /usr/bin/c++_old
mv /usr/bin/g++ /usr/bin/g++_old
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc /usr/bin/gcc
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/cpp /usr/bin/cpp
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/c++ /usr/bin/c++
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/g++ /usr/bin/g++

Return to “Project Resources”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest