升级gcc版本

CentOS

升级gcc版本的正确方式:

1
2
3
4
5
sudo yum install centos-release-scl
sudo yum install devtoolset-9-gcc*
scl enable devtoolset-9 bash
which gcc
gcc --version

9是目标的gcc版本,可以改为你需要的。

内容大致如下

1
2
3
4
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

Debian

refer to :https://linuxize.com/post/how-to-install-gcc-compiler-on-debian-10/

1
2
3
4
5
gcc --version
sudo apt update
# build-essential必安装
sudo apt install build-essential
sudo apt install manpages-dev