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?

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
/usr/bin
Answered by harryxiyou.

Weiwei Jia

Weiwei Jia is a Ph.D. student in the Department of Computer Science at New Jersey Institute of Technology since 2016. His research interests are include storage systems, operating systems and computer systems.

Leave a Reply

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