sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6 g++-6
This installed nicely on my Xenial system:
andrew@athens:~$ gcc-6 --version | head -n 2
gcc-6 (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901
Copyright (C) 2016 Free Software Foundation, Inc.
andrew@athens:~$
之后在/usr/bin 下设置一些与gcc有关的软连接就好了.