C++11 Support in GCC
GCC 4.8.1 was the first feature-complete implementation of the 2011 C++ standard, previously known as C++0x.
This mode can be selected with the -std=c++11
command-line flag, or -std=gnu++11
to enable GNU extensions as well.
如上所述, GCC4.8.1及以上版本全功能的實現了對2011 C++標准的支持. 編譯時使用編譯選項 -std=c++11就可打開C++11支持模式了.
可以本機的GCC版本還4.7.1, 已有些老邁, 而新版的GCC中也陸續新增了好多編譯選項命令字以提供更好的編譯時錯誤檢測和提示, 為了方便后續的開發,也需要將GCC升級到新的版本了.
環境:
1 [root@dln-vm-01 gcc-build-7.2.0]# uname -a 2 Linux dln-vm-01 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
當前GCC版本: 4.7.1
目標: GCC-7.2.0, 以下是升級操作記錄:
Upgrade GCC from gcc4.7.1 to 7.2.0
# // Create the directory for saving new GCC version. # mkdir GCC-7.2 # cd GCC-7.2 # wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz // Download the new version. # tar -zxvf gcc-7.2.0.tar.gz # cd gcc-7.2.0 # ./contrib/download_prerequisites // Install the dependent library automaticlly. Amazing...... 2018-04-12 01:43:02 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1] 2018-04-12 01:43:30 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1] 2018-04-12 01:43:42 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1] 2018-04-12 01:44:04 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2 [1626446] -> "./isl-0.16.1.tar.bz2" [1] gmp-6.1.0.tar.bz2: OK mpfr-3.1.4.tar.bz2: OK mpc-1.0.3.tar.gz: OK isl-0.16.1.tar.bz2: OK All prerequisites downloaded successfully. # mkdir gcc-build-7.2.0 // Create the build folder # cd gcc-build-7.2.0 # ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
// --enable-languages 告訴編譯器支持什么語言.--disable-multilib不生成編譯為其他平台可執行代碼的交叉編譯器。--disable-checking生成的編譯器在編譯過程中不做額外檢查,也可以使用--enable-checking=xxx來增加一些檢查 # make # make install # gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib Thread model: posix gcc version 7.2.0 (GCC)
# ---Game Over.