源码编译安装GCC4.8.2,体验C++11新标准 March 20, 2014 / C&C++ / apacal / 2335 CLICK / 0 comment 前言 C++11,先前被称作C++0x,即ISO/IEC 14882:2011,是目前的C++编程语言的正式标准。GCC在语言特性上全面支持C++11,目前最新的稳定版本为gcc4.8.2,本文介绍如何在linux下源码编译安装gcc4.8.2。 正文 下载源码和安装。 源码地址为http://gcc.skazkaforyou.com/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2 下载和解压 wget -c http://gcc.skazkaforyou.com/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2 tar -xjvf ./gcc-4.8.2.tar.bz2 配置和安装。 cd gcc-4.8.2/ ./contrib/download_prerequisites #下载GMP, MPFR and MPC 等库,也可以自己去下载 cd .. mkdir gcc-build-4.8.2 #建立编译输出目录 nohup ../gcc-4.8.2/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib nohup make > makeinfo #编译的步骤就已经完成了。慢慢的等待编译完成,编译好慢好慢。 make install #安装 安装完成后使用gcc -v 查看版本 gcc -v 错误1: configure: error: C++ compiler missing or inoperational make[2]: *** [configure-stage1-libcpp] Error 1 make[2]: Leaving directory `/opt/gcc-4.8.2' make[1]: *** [stage1-bubble] Error 2 make[1]: Leaving directory `/opt/gcc-4.8.2' make: *** [all] Error 2 从gcc-4.7.2(2012-09-20 released)版本开始,gcc使用c++作为其实现语言。所以我们需要事先在系统中安装低版本的g++。 Ubuntu12.04系统中自带gcc-4.6.3,但不带有g++。可以使用apt-get命令来安装。 GCC now uses C++ as its implementation language. This means that to build GCC from sources, you will need a C++ compiler that understands C++ 2003. Migrating GCC to C++ as implementation language: C++ is a standardized, well known, popular language. C++ is nearly a superset of C90 used in GCC. The C subset of C++ is just as efficient as C. C++ supports cleaner code in several significant cases. C++ makes it easier to write and enforce cleaner interfaces. C++ never requires uglier code. C++ is not a panacea but it is an improvement. apt-get install g++ 结束 编译安装gcc确实挺满的,特别是对于我这种VPS才512MB的就更慢了,推荐使用apt-get安装, Continue reading