Ubuntu20.4 install gcc11.2.0
编译安装
make时间比较长。
#直接存sh里
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.gz
tar -zxvf gcc-11.2.0.tar.gz
cd gcc-11.2.0
./contrib/download_prerequisites
mkdir build
cd build
../configure configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-11.2 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-11.2
make -j4
make install
设置默认gcc
ln -s /usr/local/gcc-11.2/bin/g++-11.2 /usr/bin/g++-11.2
ln -s /usr/local/gcc-11.2/bin/gcc-11.2 /usr/bin/gcc-11.2
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11.2 100
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11.2 100
#选择版本 就一个选项的不会提供选择
update-alternatives --config gcc
update-alternatives --config g++
gcc -v
g++ -v
Re:
https://blog.csdn.net/wbvalid/article/details/119945557
https://blog.csdn.net/EternallyAccompany/article/details/108865331