DubyaDubyaDubyaDot
DubyaDubyaDubyaDot

Reputation: 1274

When installing gcc4.7 on 12.04, GCC doesn't switch from 4.6 to 4.7

I currently have the gcc4.7 and the gcc4.7-base, etc., packages installed but GCC seems to still be using 4.6 when I call

gcc --version

I could compile the source code if I really needed it now, but I plan on converting some old code to have fun with C++11. If anyone has any suggestions on how to switch from 4.6 to 4.7 do tell.

I followed the guide from here :

https://askubuntu.com/questions/113291/installing-gcc-4-7

Edit: Fixed the issue, updated link to /usr/bin/gcc-4.7

Upvotes: 0

Views: 4114

Answers (3)

prathmesh.kallurkar
prathmesh.kallurkar

Reputation: 5686

Chances are that many programs compiled for gcc 4.6 may not work for gcc 4.7. Hence you must keep both and at the same time make the link to gcc4.7 vary according to the situation. You can edit your gcc file to be a shell script :

#!/bin/sh
if [ -n "$GCC_SIX" ]; 
then
  exec /usr/bin/gcc-4.6 "$@"
else
  exec /usr/bin/gcc-4.7 "$@"
fi

Now, whenever you find a program not working on gcc4.7 just add a new environment variable and you have switched to gcc4.6 for the current execution. Notice that for a multi-user system, this can prove to be a life saver.

Upvotes: 0

John Zwinck
John Zwinck

Reputation: 249093

You can just set your CC environment variable to /usr/bin/gcc-4.7 or whatever it is. Or maybe your build system has a different way to choose which compiler to use.

Upvotes: 1

Ross Aiken
Ross Aiken

Reputation: 952

Try running the following to see where gcc is located:

ls -l `which gcc`

I'd say that odds are all you may need to do is update the link (but then again I can't check as I'm not booted into Linux at the moment)

Upvotes: 2

Related Questions