How to switch from gcc9 to gcc10 - g++9 to g++10

Hi!

I can't switch from

gcc9 to gcc10 / g++9 to g++10

I installed all needed gcc10/g++10 packages.

When I run this commands:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

error:
update-alternatives: error: no alternatives for gcc
update-alternatives: error: no alternatives for g++
What is wrong?

Need help, thanks!

Hi @mate2go :slight_smile:

Example how to register a new alternative :

update-alternatives: --install needs <link> <name> <path> <priority>

You can get inspired what we done here for firefox :

Hi olek, :slight_smile:

Can't it be simpler?

Can not I just gcc9 + g++9 remove all packages and then re-add all packages to gcc10 + g++10?

you can try :slight_smile: if only one version is present, this should be used by the OS

ok, I hope it will not break my system. :wink:

not good:

sudo apt purge --remove gcc-9 gcc-9-base libgcc-9-dev

The following packages will be REMOVED:
alien* build-essential* cdbs* compiz-mate* cpp* cpp-9* debhelper* dh-autoreconf* dh-systemd* dh-translations* g++* g++-9* gcc* gcc-9*
gcc-9-base* gnome-pkg-tools* libasan5* libgcc-9-dev* libstdc++-9-dev* libtool* libtool-bin* mate-control-center*
mate-desktop-environment-core* mate-settings-daemon* mate-tweak* php7.2-dev* x11-xserver-utils* xorg*
0 upgraded, 0 newly installed, 28 to remove and 2 not upgraded.
After this operation, 134 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.

:frowning:

maybee work?

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

I don't know the number at the end of the command '10 or 20''?

Found here:

I did:

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

update-alternatives: using /usr/bin/gcc-10 to provide /usr/bin/gcc (gcc) in auto mode

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 20

update-alternatives: using /usr/bin/g++-10 to provide /usr/bin/g++ (g++) in auto mode

1 Like

got it now :slight_smile: I hope:

gcc -v

gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)

g++ -v

gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)

is that correct that with gcc -v and g++ -v

gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)

must stand?

shouldn't it say g++ version ... instead of gcc version 10.2.0

That's totally expected. Here's the deal: In ye olden days (circa 1986, that is), GCC stood for "GNU C Compiler". Now that the GCC package contains a C++ compiler, Objective-C, Objective-C++, Fortran, Go, Ada, and other such compilers, it's inaccurate to say that GCC stands for "GNU C Compiler"; now GCC stands for "GNU Compiler Collection". The command gcc is still named such for historical reasons, mostly because classic Unix systems had a C compiler named simply cc, and (believe it or not) most build configuration scripts you're likely to come across assume the C compiler's name ends with the suffix cc in some way or another.

In summary: That's expected. You got the commands right. You found the solution yourself, as usual.

ok @ gordon :slight_smile: