I would like to play around with some very new C++20 features. Some of them are supported by GCC10 only. Unfortunately the most current release is GCC9.3 so I need to use the unreleased version of GCC10.
I did the following to install it:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install gcc-10 g++-10
This worked fine. However I am unable to make it the default compiler. As usual I tried:
sudo update-alternatives --config gcc
This says there would be no alternatives. Why?
You can do it manually:
Then open a new terminal windows and gcc should refers to gcc-10. It should work for simple cases. If it does not, you will have to create all the appropriate symbolic links for all GCC 10 ecutables and libraries...
I think the best option is to compile yourself GCC 10 and install it in your home directory. This is what I do on my minimalist Gentoo installation, I suppose it will work too on Ubuntu:
Compilation may last about 10 minutes. Consider to adapt the
-j16
option to your machine: this is the number of jobs launched simultaneously bymake
. Using twice the number of parallel thread supported by your CPU is a good choice. Then add appropriate environment variables to your~/.bashrc
file:When you do not want to use gcc-10 any more comment out these lines and open a new terminal.