58

I would like to explore concepts and other new features in C++20, provided by g++ 10. However, I cannot seem to find any resources that allows me to apt-get a g++ 10 online?

What is the easiest way for me to get g++10 installed?

1 Answers1

72

gcc-10 is now available in the Ubuntu tool chains.

Add the PPA and install gcc-10:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install gcc-10

For g++-10:

   sudo apt install g++-10

At the end you need to update the alternatives for compilers (reference):

#Remove the previous alternatives
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++

#Define the compiler sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 30 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 30

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 sudo update-alternatives --set c++ /usr/bin/g++

#Confirm and update (You can use the default setting) sudo update-alternatives --config gcc sudo update-alternatives --config g++

Omid N
  • 160
P.P
  • 1,101