Installing newer GCC versions in Ubuntu

From Tuxamito
Revision as of 19:56, 23 November 2017 by Daniel (talk | contribs) (Created page with " <pre> $ sudo apt-get install gcc g++ gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7 </pre> <pre> $ sudo update-alternatives --remove-all gcc </pre> <pre> $ sudo update-alternatives --...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
$ sudo apt-get install gcc g++ gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7
$ sudo update-alternatives --remove-all gcc
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90 --slave /usr/bin/g++ g++ /usr/bin/g++-5
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 80 --slave /usr/bin/g++ g++ /usr/bin/g++-6
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7


$ sudo update-alternatives --config gcc
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-5   90        auto mode
  1            /usr/bin/gcc-5   90        manual mode
  2            /usr/bin/gcc-6   80        manual mode
  3            /usr/bin/gcc-7   70        manual mode

Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/gcc-7 to provide /usr/bin/gcc (gcc) in manual mode
$ g++ -v
....
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04)