您当前的位置: 首页 > 

mutourend

暂无认证

  • 2浏览

    0关注

    661博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

gcc版本编译安装

mutourend 发布时间:2020-08-17 22:46:54 ,浏览量:2

C++17自gcc 7开始完全支持。 Ubuntu16.04默认gcc 版本为5.4.0。 为了支持C++17,可升级至gcc 7.5.0版本。 升级方式为:

wget http://www.netgull.com/gcc/releases/gcc-7.5.0/gcc-7.5.0.tar.gz

解压:

mkdir build
tar -xf gcc-7.5.0.tar.gz -C ./build

安装编译GCC依赖项:(Dependency installation:build GCC requires GMP4.2+, MPFR 2.4.0+, and MPC 0.8.0+ and build essential)

sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev
sudo apt-get install build-essential

若报错“cannot find crt1.o”,则需补充安装:

sudo apt install gcc-multilib

开始配置编译:(make时间长)

cd build
mkdir /usr/local/gcc-7.5.0
../gcc-7.5.0/configure --prefix=/usr/local/gcc-7.5.0
make
make install

查看gcc、g++版本:(此时仍为默认的5.4.0)

gcc -v
g++ -v

切换gcc、g++的默认版本:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-7.5.0/bin/gcc 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-7.5.0/bin/g++ 7

再次查看gcc、g++的版本,此时为7.5.0:

gcc -v
g++ -v
参考资料

[1] How to install latest stable release of GCC in Linux Mint? [2] Compiling problems: cannot find crt1.o [3] VS版本、GCC版本与C++版本的对应关系 [4] How to switch between multiple GCC and G++ compiler versions on Ubuntu 20.04 LTS Focal Fossa

关注
打赏
1664532908
查看更多评论
立即登录/注册

微信扫码登录

0.0395s