I just installed Lubuntu 18.04 LTS. There are two options for installing gcc: gcc-7
and gcc-8
. Both are available from apt-get install
out of the box.
Even after I installed gcc-8
, the system is still going to install gcc-7
when I install other packages such as build-essential
.
Since gcc-8
is newer, is there a way to make it install gcc-8
and gcc-8
only?
gcc-7
andgcc-8
will happily co-live together.I would suggest to let
gcc-7
be installed, for satisfyingbuild-essential
and perhaps other dependent packages, and configuregcc-8
to be your default gcc installation.Use
update-alternatives
for havinggcc
redirected automatically togcc-8
:This will give you the convenience of gcc being at the latest version, and still you will be able to invoke
gcc-7
orgcc-8
directly.If you'll wish to change the default gcc version later on, run
sudo update-alternatives --config gcc
. It will bring a prompt similar to this, which lets you pick the version to be used:The higher priority is the one that is picked automatically by
update-alternatives
.Master table of all GCC versions for each Ubuntu
At: How do I use the latest GCC on Ubuntu?
GCC 8 on Ubuntu 16.04
gives 8.1.0 as of 2018-11. See also:
GCC 9 on Ubuntu 19.04
https://packages.ubuntu.com/search?keywords=gcc-9
Go download unversioned gcc packages (
cpp
/gcc
/g++
/g++multilib
/etc.) with package version 8, and install them usingdpkg -i *.deb
. Make sure you have the corresponding packages with-8
suffix installed first.http://deb.debian.org/debian/pool/main/g/gcc-defaults/
Reason:
build-essential and a lot of other packages depend on unversioned packages (no version number in package name) such as
gcc
,g++
, etc., and those unversioned packages depend on versioned packages (whose package name contains a version as suffix) such asgcc-X
,g++-X
, respectively.A unversioned package
gcc
with package version8.~
depends ongcc-8
, whereas thegcc
package in offcial Ubuntu 18.04 repository comes with package version7.~
, which in turn depends ongcc-7
.Those unversioned gcc packages install nothing, just act as dependency declaration to the versioned gcc packages.
The unversioned packages from Debian 10 (codename buster) are versioned with
8.~
. You can safely manually install them and the dependent versioned packages are still from your official ubuntu repository, so it's totally safe to do so.