在CentOS 6.4中编译安装gcc 4.8.1

原文链接: http://www.cnblogs.com/codemood/archive/2013/06/01/3113200.html

1. 安装gcc和g++
新安装的CentOS缺少编译环境,必须先安装旧版本的gcc, 然后再进行自举编译
yum -y install gcc
yum -y install gcc-c++

2. 下载gcc 4.8.1源码包
将源码包放在home目录的Download目录中

3. 解压缩gcc 4.8.1源码包
cd /home/User_Name/Downloads/
tar -zxvf gcc-4.8.1.tar.gz

4. 下载编译所需的依赖包
cd /home/ User_Name/Downloads/gcc-4.8.1
./contrib/download_prerequisites
cd ..

5. 新建目录存放编译结果
mkdir gcc-build-4.8.1

6. 进入新目录,并执行configure命令,产生makefile
cd gcc-build-4.8.1
../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib

7. 编译gcc 4.8.1
make -j4

8. 安装gcc 4.8.1
sudo make install

9. 更新libstdc++.so.6
sudo cp /home/ User_Name/Downloads/gcc-build-4.8.1/ prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.18 /usr/lib
sudo ln -sf /usr/lib/libstdc++.so.6.0.18 /usr/lib/libstdc++.so.6
红字部分在不同平台上有所不同

10. 检查版本
g++ --version
g++ (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc --version
gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页