Installing gcc-7.2 via apt

how do I install gcc-7.2 via apt on zesty? Anything I found is either installing 7.0.1 or for installing gcc on Ubuntu 16.10

Answer

The Ubuntu maintainers have some alpha-quality/unsupported gcc 7.2 packages that might work. Use at your own risk

$ gcc-7 -v
...
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04)
$

Install it (should work on Trusty to Zesty)

sudo env DEBIAN_FRONTEND=noninteractive                                    \
     bash -c 'apt-get install -y python-software-properties lsb-release && \
            echo -e "Package: gcc-7\\nPin: release n=$(lsb_release -sc)\\nPin-Priority: 990" > /etc/apt/preferences.d/gcc-7 \
            apt-add-repository -yu ppa:ubuntu-toolchain-r/test &&              \
            apt-get install -y gcc-7'

More resources, including compiling DIY

  1. https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
  2. How do I install g++-7 on Ubuntu?
  3. https://help.ubuntu.com/community/CompilingEasyHowTo
  4. https://help.ubuntu.com/community/AutoApt
  5. https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/
  6. http://eli.thegreenplace.net/2014/01/16/building-gcc-4-8-from-source-on-ubunu-12-04/
  7. http://www.linuxfromscratch.org/lfs/view/8.1-systemd/chapter05/gcc-pass2.html
  8. https://gcc.gnu.org/wiki/InstallingGCC

Attribution
Source : Link , Question Author : Andrei R. , Answer Author : dhchdhd

Leave a Comment