Linux升级GCC从4.7.1到7.2.0

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.

原文链接: https://www.cnblogs.com/yicheng-bangbang/p/8809346.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/272208

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月14日 下午10:31
下一篇 2023年2月14日 下午10:32

相关推荐