首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ubuntu 选择gcc 版本

ubuntu 选择gcc 版本

作者头像
bear_fish
发布2018-09-19 12:40:35
1.9K0
发布2018-09-19 12:40:35
举报

http://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu

To figure out the current priorities of gcc, type in the command pointed out by @tripleee's comment:

查看当前的可切换的版本: update-alternatives --query gcc
例如有 4.6 4.5 两个版本
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 100
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.5 50
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 100
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.5 50
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.6 100
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.5 50
设置为4.5

update-alternatives --set g++ /usr/bin/g++-4.5update-alternatives --set gcc /usr/bin/gcc-4.5update-alternatives --set cpp-bin /usr/bin/cpp-4.5

Here, 4.6 is still the default (aka "auto mode"), but I explicitly switch to 4.5 temporarily (manual mode). To go back to 4.6:

update-alternatives --auto g++
update-alternatives --auto gcc
update-alternatives --auto cpp-bin

方法二:

echo 'export CXX=/usr/bin/gcc-4.5' >> ~/.bashrc
移除当前的选择可以这样

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

Install PackagesIt seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages:sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4

First erased the current update-alternatives setup for gcc and g++: sudo update-alternatives --remove-all gcc sudo update-alternatives --remove-all g++ Install Packages It seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages: sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年01月12日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档