how to install older version gcc/g++ in Ubuntu (other linux distro are similar)

When we compile some project, it needs older version gcc/g++ version. So how to insall older ones in ubuntu 16?

Install older gcc/g++ version

sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib

Set gcc/g++ version to be used automatically

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 50
sudo update-alternatives --install /usr/bin/g++ gcc /usr/bin/g++-4.4 50

You may need to create a symbolink for gcc-4.4 as follows

node2@node2:/usr/bin$ sudo ln -s gcc-4.4 gcc
node2@node2:/usr/bin$ sudo ln -s g++-4.4 g++
node2@node2:/usr/bin$ pwd


Leave a Reply

Your email address will not be published. Required fields are marked *