This guide shows you how to install
GCC, specifically downgrading GCC versions. However, the methods shown here can also be used to update GCC versions. You just have to solve whatever library dependencies that arise with upgrading. Typically, each successive GCC version solves its predecessor’s dependencies.
For all of these methods, you will need to unlink your current GCC version and link the version you want. Towards the end of this guide, I will show you how to link gcc globally.
The first method of installing any gcc version is using the package manager native to your OS flavor. Some of these package managers are apt-get, yum, opkg, and ipkg.
apt-get install gcc-[version]
Depending on the package manager you are using, the package manager may or may not install missing dependencies. In my example, apt-get doesn’t install dependencies. One alternative that I use sometimes is aptitude.
aptitude install gcc-[version]
Another way to install GCC versions without a package manager is through compiling. This method requires more work.
i. Make a new directory for the GCC files
mkdir gcc-4.8-files cd gcc-4.8-files
ii. Download GCC-4.8 from a mirror
You can find all GCC versions here.
iii. Untar the file
iv. Install some dependencies
sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev
Note: there may be more dependencies you may need.
v. Compile the source files
vi. Run the Makefile
vii. Install the source files
sudo make install
1. Now to symbolically link GCC-4.8. But first, let’s get rid of GCC-4.9 if that is still on your device.
apt-get remove gcc-4.9
2. Navigate to /usr/bin/ and GCC-4.8 should be there
3. Symbolically link GCC-4.8
ln -s gcc-4.8 gcc ln -s gcc-4.8 cc
4. Check to verify GCC-4.8 is your current active compiler