As you may know, Ubuntu 14.04 comes with GCC 4.8.4 which is sometimes not up to date enough to compile some project. You may want to install 4.9 or higher but "apt-get install gcc-4.9" will report that the gcc-4.9-base is already up-to-date.
Here are the steps to install the real compiler on Ubuntu 14.04.
First, you need to ensure you have "add-apt-repository" command installed. If not, install it byapt-get install software-properties-common
PS: for Ubuntu version lower than 12, you need: sudo apt-get install python-software-properties
Second, add test ppa repo:add-apt-repository ppa:ubuntu-toolchain-r/test
and update your library apt-get update
Third, install the new gcc:apt-get install gcc-4.9 g++-4.9 cpp-4.9
Lastly, update the symbolic links or you will not able to compile with the typical gcc command.
There are mainly two ways to do it.
Create links manually
cd /usr/bin
rm gcc g++ cpp
ln -s gcc-4.9 gcc
ln -s g++-4.9 g++
ln -s cpp-4.9 cppUse update alternatives command
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 48 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.8 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-4.8 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-4.8 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-4.8update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 49 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.9 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-4.9 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-4.9 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-4.9update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 53 \
--slave /usr/bin/g++ g++ /usr/bin/g++-5 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-5 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-5 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-5
Now, try gcc -v and see it reports the correct version.
0 comment