centos6.5安装gcc6.1等c++环境
wget http://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
tar -jxvf gcc-6.1.0.tar.bz2
2、下载供编译需求的依赖项
执行download_prerequisites将会自动下载这些软件并解压到当前目录,生成gcc编译的make文件。自动安装gcc需要下载诸如gmp、mpfr、mpc等依赖文件,
cd gcc-6.1.0
./contrib/download_prerequisites
如果你的Linux无法直接联网,那么你只能打开文件download_prerequisites,获取到这些文件的下载链接,然后通过其他上网设备下载这些软件。最后把这些软件直接解压到gcc源程序目录(/路径/6.1.0)下即可。
3、建立一个目录供编译出的文件存放
mkdir gcc-build-6.1.0; cd gcc-build-6.1.0
-j4选项是make对多核处理器的优化,如果不成功请使用 make
6 安装gcc
make install
7 验证安装
截至目前,GCC 6.1.0编译安装了,但还需要替换系统的链接库:/usr/lib/libstdc++.so.6
拷贝文件到目录下:cp /usr/local/lib64/libstdc++.so.6.0.22 /usr/lib64/,进入lib目录:cd /usr/lib64,删除原来的文件:rm libstdc++.so.6,
重新建立软连接:ln libstdc++.so.6.0.17 libstdc++.so.6 。替换完成
附:
GCC 6.1 发布了,该版本较之前GCC5 新怎了大量的功能特性,默认采用C++14为新的标准,替代了之前的C++98。OpenMP 4.5规范将在本版本中被支持。此外,GCC 6.1 增强了对 C++17 的试验性支持;大大改进了诊断特性,包括位置,位置范围,拼写错误标识符建议,选项名字等等改进;新增了修复提示和一些警告提示。改进记录如下:
-
UndefinedBehaviorSanitizer gained a new sanitization option,
-fsanitize=bounds-strict
, which enables strict checking of array bounds. In particular, it enables-fsanitize=bounds
as well as instrumentation of flexible array member-like arrays. -
Type-based alias analysis now disambiguates accesses to different pointers. This improves precision of the alias oracle by about 20-30% on higher-level C++ programs. Programs doing invalid type punning of pointer types may now need
-fno-strict-aliasing
to work correctly. -
Alias analysis now correctly supports
weakref
andalias
attributes. This makes it possible to access both a variable and its alias in one translation unit which is common with link-time optimization. -
Value range propagation now assumes that the
this
pointer of C++ member functions is non-null. This eliminates common null pointer checks but also breaks some non-conforming code-bases (such as Qt-5, Chromium, KDevelop). As a temporary work-around-fno-delete-null-pointer-checks
can be used. Wrong code can be identified by using-fsanitize=undefined
.
完整发布说明,可以在这里查看。