When installing gcc4.7 on 12.04, GCC doesn't s

2019-09-01 04:13发布

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

3条回答
做个烂人
2楼-- · 2019-09-01 04:55

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.

查看更多
家丑人穷心不美
3楼-- · 2019-09-01 04:59

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.

查看更多
Lonely孤独者°
4楼-- · 2019-09-01 05:00

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)

查看更多
登录 后发表回答