centos升级gcc到4.8.1(支持c++11)步骤
2014-04-23 12:30
288 查看
[root@localhost ~]#
下载gcc最新版
[root@localhost ~]# wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.gz
然后解压到文件夹
[root@localhost ~]# tar -zxvf gcc-4.8.1.tar.gz
[root@localhost ~]# cd /root/gcc-4.8.1
[root@localhost ~]# ./contrib/download_prerequisites
[root@localhost contrib]# cd ..
[root@localhost ~]#mkdir build_gcc_4.8.1
[root@localhost build_gcc_4.8.1]# cd build_gcc_4.8.1
[root@localhost build_gcc_4.8.1]# ../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
[root@localhost build_gcc_4.8.1]# make -j
[root@localhost build_gcc_4.8.1]# make install
[root@localhost build_gcc_4.8.1]# ls /usr/local/bin | grep gcc
[root@localhost build_gcc_4.8.1]# /usr/sbin/update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/i686-pc-linux-gnu-gcc-4.8.1 40
[root@localhost build_gcc_4.8.1]# gcc --version
gcc (GCC) 4.8.1
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
[root@localhost build_gcc_4.8.1]# /usr/sbin/update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 40
[root@localhost build_gcc_4.8.1]# g++ --version
g++ (GCC) 4.8.1
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
测试一下c++ 11的新功能:
#include <array>
#include <iostream>
using namespace std;
int main()
{
std::array<int, 3> arr = {2, 3, 5};
for(auto& s : arr){
cout << s << endl;
}
}
编译:
g++ test_11.c -std=gnu++0x或g++ test_11.c -std=c++0x
./a.out
输出:
2
3
5
下载gcc最新版
[root@localhost ~]# wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.gz
然后解压到文件夹
[root@localhost ~]# tar -zxvf gcc-4.8.1.tar.gz
[root@localhost ~]# cd /root/gcc-4.8.1
[root@localhost ~]# ./contrib/download_prerequisites
[root@localhost contrib]# cd ..
[root@localhost ~]#mkdir build_gcc_4.8.1
[root@localhost build_gcc_4.8.1]# cd build_gcc_4.8.1
[root@localhost build_gcc_4.8.1]# ../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
[root@localhost build_gcc_4.8.1]# make -j
[root@localhost build_gcc_4.8.1]# make install
[root@localhost build_gcc_4.8.1]# ls /usr/local/bin | grep gcc
[root@localhost build_gcc_4.8.1]# /usr/sbin/update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/i686-pc-linux-gnu-gcc-4.8.1 40
[root@localhost build_gcc_4.8.1]# gcc --version
gcc (GCC) 4.8.1
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
[root@localhost build_gcc_4.8.1]# /usr/sbin/update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 40
[root@localhost build_gcc_4.8.1]# g++ --version
g++ (GCC) 4.8.1
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
测试一下c++ 11的新功能:
#include <array>
#include <iostream>
using namespace std;
int main()
{
std::array<int, 3> arr = {2, 3, 5};
for(auto& s : arr){
cout << s << endl;
}
}
编译:
g++ test_11.c -std=gnu++0x或g++ test_11.c -std=c++0x
./a.out
输出:
2
3
5
相关文章推荐
- centos升级gcc到4.8.1(支持c++11)步骤
- centos升级gcc到4.8.1(支持c++11)步骤
- centos升级gcc到4.8.1(支持c++11)步骤
- ubuntu升级gcc和g++到4.8(支持c++11)步骤
- centos升级支持到C++11, gcc4.8.2
- centos升级gcc支持c++11
- GCC升级 支持C++11
- CentOS 编译安装gcc 4.8 为了支持C++11新特性
- CentOS 6.4中升级编译安装GCC 4.8.1 + GDB 7.6.1 + Eclipse 以及Kdump配置
- GCC 升级4.8 支持c++11
- 升级gcc/d++ 让Linux支持c++11
- CentOS gcc升级4.8步骤
- CentOS 6.5下升级GCC编译器到4.9.1版本的方法、步骤
- linux下安装或升级GCC 4.8,以支持C++11标准
- CentOS 6.5下升级GCC编译器到4.9.1版本的方法、步骤
- Linux GCC升级4.8.2 支持C++11 (CentOS)
- ubuntu10.10升级gcc到4.7------以便支持C++11
- linux升级gcc支持c++11
- 升级centos6.5系统的gcc为4.8.5的简易步骤
- CentOS6.5升级手动安装GCC4.8.2 与 CentOS 6.4 编译安装 gcc 4.8.1