Problem: cpp-10 is default in Debian 11

Need: cpp-9 or gcc-9 as default

Solution:

sudo apt install build-essential cpp-10 cpp-9 gcc-10 gcc-9

sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 10
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-10 20

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 20

update-alternatives --query cpp
update-alternatives --query gcc

update-alternatives --config cpp
update-alternatives --config gcc

Resource: https://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu

Potential problems:
If you get something like update-alternatives: error: cannot stat file '/usr/bin/cpp': Too many levels of symbolic links, then sudo rm /etc/alternatives/cpp. BUT be sure to reinstall cpp-* to get the /user/bin links recreated.

~~
good luck!


Original link: https://steronius.blogspot.com/2021/10/set-cpp-9-or-gcc-9-as-default-in-debian.html