How to switch the whole GCC from v4.4 to v4.5 in Maverick?

Asked by Uqbar on 2011-04-01

I see I have both v4.4 and v4.5 installed (by default?) on my Maverick machine.
v4.4 is the one currently in use.
I've seen also that /usr/bin has a number of symlinks to handle it:
ls -l /usr/bin | grep '4\.[45]'
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 cpp -> cpp-4.4
-rwxr-xr-x 1 root root 224488 2010-09-27 20:41 cpp-4.4
-rwxr-xr-x 1 root root 237008 2010-09-27 23:00 cpp-4.5
lrwxrwxrwx 1 root root 7 2011-03-10 20:01 g++ -> g++-4.4
-rwxr-xr-x 1 root root 228520 2010-09-27 20:42 g++-4.4
-rwxr-xr-x 1 root root 236944 2010-09-27 23:01 g++-4.5
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 gcc -> gcc-4.4
-rwxr-xr-x 1 root root 224488 2010-09-27 20:43 gcc-4.4
-rwxr-xr-x 1 root root 232912 2010-09-27 23:03 gcc-4.5
lrwxrwxrwx 1 root root 8 2011-03-10 17:29 gcov -> gcov-4.4
-rwxr-xr-x 1 root root 30212 2010-09-27 20:43 gcov-4.4
-rwxr-xr-x 1 root root 30216 2010-09-27 23:03 gcov-4.5
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 i686-linux-gnu-cpp -> cpp-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 i686-linux-gnu-cpp-4.4 -> cpp-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 19:59 i686-linux-gnu-cpp-4.5 -> cpp-4.5
lrwxrwxrwx 1 root root 7 2011-03-10 20:01 i686-linux-gnu-g++ -> g++-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 20:00 i686-linux-gnu-g++-4.4 -> g++-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 20:01 i686-linux-gnu-g++-4.5 -> g++-4.5
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 i686-linux-gnu-gcc -> gcc-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 17:29 i686-linux-gnu-gcc-4.4 -> gcc-4.4
lrwxrwxrwx 1 root root 7 2011-03-10 20:01 i686-linux-gnu-gcc-4.5 -> gcc-4.5

I'd like to be able to drive the switch in a complete and safe way.
How to?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
Uqbar
Solved:
2011-04-14
Last query:
2011-04-14
Last reply:
2011-04-14
Uqbar (uqbar) said : #1

No way?

It think the lowest-impact way to do this would be to create a new directory, such as /usr/local/bin/gcc-4.5, fill it with symbolic links whose names are unversioned and which point to the version 4.5 binaries (for example, it would contain a symbolic link called gcc and pointed at /usr/bin/gcc-4.5), and then edit the global profile file (/etc/profile) or specific users' local profile files (~/.profile) so as to put this directory in the path somewhere before /usr/bin.

(It occurs to me that, for consistency with the way that alternate versions of GCC are often manually installed, it would make more sense to call this special directory /usr/local/gcc-4.5/bin.)

Uqbar (uqbar) said : #4

Eliah, your suggestions makes a lot of sense, but I won't do that.
Instead I will open a bug as I appears to me that there should be a system tool for such a switch.
Leaving a symlink behind could yield to some unexpected behaviour either in the compiler itself or in the binaries.