Installing cpp-13, gcc-13 and g++-13 in Debian 12
Continuing from my previous post for setting default versions of cpp, gcc & clang, here I describe how to install cpp-13
on Debian 12.
Problem:
Debian 12 only contains up to cpp-12.
Solution:
Download, compile, install and configure cpp-13
, gcc-13
, g++-13
:
wget https://gcc.gnu.org/pub/gcc/releases/gcc-13.3.0/gcc-13.3.0.tar.gz
tar -xvzf gcc-13.3.0.tar.gz
cd gcc-13.3.0
make distclean
./contrib/download_prerequisites
./configure --disable-multilib --enable-languages=c,c++ --program-suffix=-13
make -j3
sudo make install
sudo update-alternatives --install /usr/bin/cpp cpp /usr/local/bin/cpp-13 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc-13 50
Where 50
is the next level used due to my aforementioned blogpost. We can now check the default version:
$ cpp --version
cpp (GCC) 13.3.0
[...]
$ gcc --version
gcc (GCC) 13.3.0
[...]
Defaults can be changed via:
sudo update-alternatives --config cpp
sudo update-alternatives --config gcc
Notes: I found make distclean
to be necessary for every compile attempt, as any change of configuration will cause compile error. Furthermore, There may be ./configure
parameters to change the install location which i did not use here. As per GNU gcc
documentation there is no make uninstall
, so be cautioned that removal will need to be manually performed (/usr/local/bin/
--> specific files, not all contents).
Alternative:
Use a PPA as per https://markusthill.github.io/blog/2024/installing-gcc/
Resources:
- https://stackoverflow.com/a/79119168/2013805 (including comments)
- https://gcc.gnu.org/install/
- https://steronius.blogspot.com/2021/10/set-cpp-9-or-gcc-9-as-default-in-debian.html
- https://stackoverflow.com/a/70653945/2013805
~~ good luck!