CentOS7默认的GCC版本是4.8,不支持C++14,对C++11支持也不完善,编译时需要加上-std=c++11才能勉强支持C++11,所以对GCC来个升级。
因为3.10的内核实在太老,加之GCC4.8和最新的GCC8.2代差太大,直接用GCC4.8编译安装GCC7或8是不能成功的,我选择了GCC6.5,6.5对C++11支持很完美,还支持C++14.
-
1、下载和解压源码
这里列出了GCC主要的几个镜像站,很遗憾亚洲只有日本一个,国内一个都没有
https://gcc.gnu.org/mirrors.html
GCC mirror sites
Our releases are available on the GNU FTP server and its mirrors. The following sites mirror the gcc.gnu.org FTP site (Phoenix, Arizona, USA) directly:
- France (no snapshots): ftp.lip6.fr, thanks to ftpmaint at lip6.fr
- France, Brittany: ftp.irisa.fr, thanks to ftpmaint at irisa.fr
- France, Versailles: ftp.uvsq.fr, thanks to ftpmaint at uvsq.fr
- Germany, Berlin: ftp.fu-berlin.de, thanks to ftp at fu-berlin.de
- Germany: ftp.gwdg.de, thanks to emoenke at gwdg.de
- Germany: ftp.mpi-sb.mpg.de, thanks to ftpadmin at mpi-sb.mpg.de
- Germany: http://gcc.cybermirror.org, thanks to Sascha Schwarz (cm at cybermirror.org)
- Greece: ftp.ntua.gr, thanks to ftpadm at ntua.gr
- Hungary, Budapest: robotlab.itk.ppke.hu, thanks to Adam Rak (neurhlp at gmail.com)
- Japan: ftp.tsukuba.wide.ad.jp, thanks to Kohei Takahashi (tsukuba-ftp-servers at tsukuba.wide.ad.jp)
- The Netherlands, Dronten: http://mirror.koddos.net/gcc/ | rsync://mirror.koddos.net/gcc/, thanks to Martin (mirror@koddos.net) at KoDDoS.
- The Netherlands, Nijmegen: ftp.nluug.nl, thanks to Jan Cristiaan van Winkel (jc at ATComputing.nl)
- Russia, Novosibirsk: http://mirror.linux-ia64.org/gnu/gcc/, thanks to Daniel Volchixin <daniel@volchixin.co.uk>
- Slovakia, Bratislava: gcc.fyxm.net, thanks to Jan Teluch (admin at 2600.sk)
- UK: ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/, thanks to mirror at mirrorservice.org
- US, San Francisco: https://bigsearcher.com/mirrors/gcc/, thanks to info@bigsearcher.com
- US, San Jose: