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

a 夏天 提交于 2019-12-11 19:55:10

问题


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


回答1:


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)




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9985840/when-installing-gcc4-7-on-12-04-gcc-doesnt-switch-from-4-6-to-4-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!