3

I'm using Ubuntu 18.04 LTS, when I try to install g++-10:

sudo apt install g++-10

it installs clang-10, but I don't need clang-10, I strictly need a g++-10

  • 2
    I suspect that's because there is no g++-10 available in any of the repositories that are configured for your system (it's not in the default Ubuntu repositories), so apt is treating g++-10 as a regex and matching anything with at least one g followed by -10. AFAIK if you want to install g++-10 on 18.04 you will need to do so from a PPA (I use the toolchain-r PPA myself) – steeldriver May 27 '21 at 12:24

2 Answers2

7

The issue here is that the default Ubuntu 18.04 repositories don't contain g++-10 (but do contain clang-10)

On 18.04, if apt fails to match an exact package name, it expands the name as a regular expression1. In this context, the + character means "one or more of the preceding character" so g++-10 matches clang-10 (it's just coincidental that they're both compilers).

If you want gcc-10 / g++-10 on 18.04 you can do so by adding the toolchain-r PPA to your repositories:

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

See also


Notes:

  1. it no longer does that - see for example Problem using wildcard with apt
steeldriver
  • 136,215
  • 21
  • 243
  • 336
1
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install g++-10