Setting GCC version to 3.3

Michael Williams williams at thphys.ox.ac.uk
Sun Mar 12 20:03:04 UTC 2006


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?

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)

The -n switch tells you what changes have been made:

mike at sannr023:~$ sudo gcc_select -n 3.3
Commands that would be executed if "-n" were not specified:
   mkdir -p /usr/bin
   rm -f /usr/bin/cc /usr/bin/c++
   rm -f /usr/bin/cc.real
   rm -f /usr/bin/c++.real
   rm -f /usr/bin/gcc.real
   rm -f /usr/bin/g++.real
   rm -f /usr/bin/gcov.real
   ln -sf gcc-3.3 /usr/bin/cc
   ln -sf g++-3.3 /usr/bin/c++
   rm -f /usr/bin/gcc
   ln -sf gcc-3.3 /usr/bin/gcc
   rm -f /usr/bin/g++
   ln -sf g++-3.3 /usr/bin/g++
   rm -f /usr/bin/gcov
   ln -sf gcov-3.3 /usr/bin/gcov
   mkdir -p /usr/include/gcc/darwin
   rm -f /usr/include/gcc/darwin/default
   ln -sf 3.3 /usr/include/gcc/darwin/default
   mkdir -p /usr/libexec/gcc/darwin/i386
   rm -f /usr/libexec/gcc/darwin/i386/default
   ln -sf 3.3 /usr/libexec/gcc/darwin/i386/default
   mkdir -p /usr/libexec/gcc/darwin/ppc
   rm -f /usr/libexec/gcc/darwin/ppc/default
   ln -sf 3.3 /usr/libexec/gcc/darwin/ppc/default
   mkdir -p /usr/lib/gcc/darwin
   rm -f /usr/lib/gcc/darwin/default
   ln -sf 3.3 /usr/lib/gcc/darwin/default
   mkdir -p /usr/lib
   rm -f /usr/lib/libcc_dynamic.a
   rm -f /usr/lib/libcc_kext.a
   rm -f /usr/lib/libgcc.a
   rm -f /usr/lib/libcc.a
   rm -f /usr/lib/libstdc++.a
   rm -f /usr/lib/libsupc++.a
   mkdir -p /usr/local/lib
   rm -f /usr/local/lib/libcc_noc++.a
   ln -sf gcc/darwin/default/libgcc.a /usr/lib/libcc_dynamic.a
   mkdir -p /usr/include
   rm -f /usr/include/stdint.h
   ln -sf gcc/darwin/default/stdint.h /usr/include/stdint.h
   mkdir -p /usr/share/man/man1
   rm -f /usr/share/man/man1/c++.1
   ln -sf c++-3.3.1 /usr/share/man/man1/c++.1
   rm -f /usr/share/man/man1/g++.1
   ln -sf g++-3.3.1 /usr/share/man/man1/g++.1
   rm -f /usr/share/man/man1/gcc.1
   ln -sf gcc-3.3.1 /usr/share/man/man1/gcc.1
   rm -f /usr/share/man/man1/gcov.1
   ln -sf gcov-3.3.1 /usr/share/man/man1/gcov.1
   rm -f /usr/share/man/man1/cpp.1
   ln -sf cpp-3.3.1 /usr/share/man/man1/cpp.1
   rm -rf /usr/share/man/man1/cc.1
   ln -sf gcc.1 /usr/share/man/man1/cc.1

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!

-- Mike




More information about the ubuntu-users mailing list