前几天想着换 GCC 版本,编译完发现没法用(缺少
GLIBCXX-3.4.32)研究了一下
编译安装
下载源码 gcc-14.2.0.tar.gz
解压
1
| tar -xvf ./gcc-14.2.0.tar.gz
|
你可能需要先安装 build-essentials
等编译环境
1 2
| sudo apt install build-essential -y sudo apt install libmpfr-dev libgmp3-dev libmpc-dev -y
|
随后进入目录,进行编译
1 2 3 4
| cd ./gcc-14.2.0 ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.2.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.2.0 make -j sudo make install
|
切换 GCC 版本
推荐使用 config
1 2
| sudo update-alternatives --config gcc sudo update-alternatives --config g++
|
解决缺少 GLIBCXX-3.4.32
的问题
1 2 3
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install libstdc++6
|
测试
g++1 2 3 4 5 6 7 8 9 10
| iy88@DESKTOP:~$ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/gcc-14.2.0/libexec/gcc/x86_64-linux-gnu/14.2.0/lto-wrapper Target: x86_64-linux-gnu Configured with: ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.2.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.2.0 Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.2.0 (GCC) iy88@DESKTOP:~$
|
gcc1 2 3 4 5 6 7 8 9 10
| iy88@DESKTOP:~$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/gcc-14.2.0/libexec/gcc/x86_64-linux-gnu/14.2.0/lto-wrapper Target: x86_64-linux-gnu Configured with: ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.2.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.2.0 Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.2.0 (GCC) iy88@DESKTOP:~$
|