CentOS 编译安装gcc 4.8 为了支持C++11新特性




gcc属于gun软件,下载gun所有软件

ftp://ftp.gnu.org/gnu/

ftp://ftp.gnu.org/gnu/gcc



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
[[email protected]]$./contrib/download_prerequisites
[[email protected]]$echo$?
[[email protected]]$./configure--enable-checking=release--enable-languages=c,c++--disable-multilib
[[email protected]]$echo$?
[[email protected]]$make
[[email protected]]$echo$?
[[email protected]]$sudoyumremovegccg++gcc-c++
[[email protected]]$sudomakeinstall
[[email protected]]$echo$?
[[email protected]]$logout#重新登录一次,识别新的gcc文件路径
chunli@linux:[email protected]
[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~]$

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native