gcc属于gun软件,下载gun所有软件
1,编译gcc的时候,还是需要存在gcc,g++
2,等编译完成,卸载系统的gcc,g+++
3,测试c++11
[chunli@CentOS~]$sudoyuminstallgccgcc-c++ [chunli@CentOS~]$wgetftp://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2 [chunli@CentOS~]$taxxfgcc-4.8.5.tar.bz2 [chunli@CentOS~]$cdgcc-4.8.5 [chunli@CentOSgcc-4.8.5]$./contrib/download_prerequisites [chunli@CentOSgcc-4.8.5]$echo$? [chunli@CentOSgcc-4.8.5]$./configure--enable-checking=release--enable-languages=c,c++--disable-multilib [chunli@CentOSgcc-4.8.5]$echo$? [chunli@CentOSgcc-4.8.5]$make [chunli@CentOSgcc-4.8.5]$echo$? [chunli@CentOSgcc-4.8.5]$sudoyumremovegccg++gcc-c++ [chunli@CentOSgcc-4.8.5]$sudomakeinstall [chunli@CentOSgcc-4.8.5]$echo$? [chunli@CentOSgcc-4.8.5]$logout#重新登录一次,识别新的gcc文件路径 chunli@linux:~$sshchunli@172.16.20.118 [chunli@CentOS~]$gcc--version gcc(GCC)4.8.5 [chunli@CentOS~]$g++--version g++(GCC)4.8.5
测试C++11
测试C++11 [chunli@CentOS~]$catmain.cpp #include<iostream> usingnamespacestd; intmain(intargc,char**argv) { autofn=[](inta,intb){returna+b;}; intc=fn(2,3); cout<<"result:"<<c<<endl; return0; } [chunli@CentOS~]$g++-std=c++11main.cpp&&./a.out result:5 [chunli@CentOS~]$原文链接:https://www.f2er.com/centos/378504.html