Setting GCC version to 3.3

Reinhard Tartler siretart at tauware.de
Sun Mar 12 21:06:27 UTC 2006


Michael Williams wrote:
> Hi,
>
> I have inherited a scientific program which depends on an ancient  
> version of the Blitz C++ library and Fortran 77. All attempts to  
> rebuild the system with gcc 4.0 have failed, so I have installed  
> gcc-3.3 and g++-3.3. The program builds with these versions of gcc,  
> so I would like to use gcc by default on my system.
>
> I note /usr/bin/gcc and /usr/bin/g++ are currently symlinks to  
> gcc-4.0 and g++-4.0 respectively. This website <http:// 
> viral.media.mit.edu/wiki/tiki-index.php?page=UbuntuPeersInstall>  
> seems to suggest that changing these symlinks (and those to gcov and  
> gccbug) is all there is to changing my default gcc version. Is this a  
> good idea? For example, would I still be able to build Ubuntu  
> packages from source, or do these expect the gcc symlink to point to  
> a particular version?

I find this a very bad idea. It seems to me quite clumsy and very
errorprone. Most sensible Makefiles respect the Variables CC for the
C-compiler and CXX for the c++ compiler. So setting them on the shell
like that should work for most Makefiles:

export CC=gcc-3.3
export CXX=g++-3.3

> Also, based on my experience of Mac OS X, which also ships with  
> gcc-4.0 as the default, I'm not convinced shifting these symlinks  
> around is all I have to do. Mac OS X a useful script called  
> gcc_select is provided:
>
> mike at sannr023:~$ sudo gcc_select 3.3
> Default compiler has been set to:
> gcc version 3.3 20030304 (Apple Computer, Inc. build 1809)
> mike at sannr023:~$ sudo gcc_select 4.0
> Default compiler has been set to:
> gcc version 4.0.0 (Apple Computer, Inc. build 5026)

I assume this affects all users on that machine. Ugly :/

> In particular, it seems to be shifting around some library and man  
> page links. I'd be very grateful if someone would tell this Ubuntu  
> newbie if there is an "Ubunte/Debian way" of doing this, or whether  
> it's just a terrible idea!

If you have no luck with setting CC and CXX, try the following:

mkdir ~/bin
cd ~/bin
ln -s /usr/bin/gcc-3.3 gcc
ln -s /usr/bin/gcc-3.3 g++
export PATH=~/bin:$PATH

and try compiling again.

Does only affect your current shell, no other users are harmed, and
easily undone.


Greetings,
	Reinhard






More information about the ubuntu-users mailing list