sudo apt install build-essential
gcc --version (查看gcc版本)
可以看到我的gcc版本是4.8.5
![](https://img-blog.csdnimg.cn/16d8d68a0f164c63973a30f571de8044.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6I6r5YWLX0NoZW5leQ==,size_15,color_FFFFFF,t_70,g_se,x_16)
安装最新版gcc9
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install gcc-9 g++-9
查看各个gcc版本的优先级,分数越高优先级越高
sudo update-alternatives --config gcc
![](https://img-blog.csdnimg.cn/241a6ebce2b84b85bbf2e9ba7be2916d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6I6r5YWLX0NoZW5leQ==,size_16,color_FFFFFF,t_70,g_se,x_16)
更改优先级(可以用以下命令,将你想要的gcc版本优先级改为最高)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)