Saturday, January 22, 2011

How to use older version of gcc

Hi all,

This post is for my friends who want to use an older version of gcc/g++ compiler but don't know how (Assuming they are on latest Ubuntu where in the default g++ package installs 4.4 or above). In synaptic versions of gcc ranging from 4.1 are available (at-least they do on Ubuntu 9.10).
When i first googled/binged the question, it was difficult for me to get an answer. No were its mentioned on how to use older version. But just by luck i tired "g++-4.1" and it worked like charm :)

For using an older version (Off-course after installation) supply the version number along with g++ command, eg for version 4.3 use "g++-4.3" no space in between. It will compile the code.


Why we need older versions ??

Its mainly because sites like http://www.codechef.com/ etc support gcc 4.3 but not above (The last time i saw), there is considerable difference between various versions of gcc () , which most of the time must not matter to a user. But sometimes when compiling a old code (I was stuck with COOL language in my compilers assignment), one need an older version.

The changes incorporated in various versions are available at http://gcc.gnu.org/ in the form of change logs.


By default g++ will map to the highest version of g++ installed (by selecting g++ or g++ multilib in synaptic). I think there must be a way to change this mapping . Any one know about it ??

1 comment: