在CentOS 6.4中编译安装GCC 4.8.1 + GDB 7.6.1 + Eclipse

CentOS 6.4中编译安装GCC 4.8.1 + GDB 7.6.1 + Eclipse

一、编译安装gcc 4.8.1

1. 安装gcc和g++

新安装的CentOS缺少编译环境,必须先安装旧版本的gcc, 然后再进行自举编译

yum -y install gcc 
yum -y install gcc-c++

2. 下载gcc 4.8.1源码包

http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.gz

将源码包放在home目录的Download目录中

3. 解压缩gcc 4.8.1源码包

cd /root/Downloads/

tar -zxvf gcc-4.8.1.tar.gz

4. 下载编译所需的依赖包

cd /root/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 /root/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

红字部分在不同平台上有所不同,注意,如果是64位系统,则命令中的lib要替换为lib64

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.

二、编译安装gdb 7.6.1

1. 先卸载gdb旧版本

rpm -qa | grep gdb

rpm -e --nodeps gdb-7.2-60.el6_4.1.i686

 

2. 安装Texinfo文档系统

yum install ncurses-devel

 

3. 下载gdb 7.6.1源码包

http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz

将源码包放在home目录的Download目录中

4. 解压缩gdb 7.6.1源码包

cd /root/Downloads/

tar -zxvf gdb-7.6.1.tar.gz

5. 生成makefile

cd /root/Downloads/gdb-7.6.1

./configure

make

sudo make install

6. 将编译好的gdb拷贝到/usr/bin目录中 
sudo cp /root/Downloads/gdb-7.6.1/gdb/gdb /usr/bin/gdb 
7. 查看安装是否成功。 
gdb -v

三、安装Eclipse

1. 下载Eclipse IDE for C/C++ Developers

cd /root/Downloads

wget http://mirror.hust.edu.cn/eclipse//technology/epp/downloads/release/luna/R/eclipse-cpp-luna-R-linux-gtk-x86_64.tar.gz

2. 解压安装Eclipse

tar xvzf eclipse-cpp-luna-R-linux-gtk-x86_64.tar.gz

mv /root/Downloads/eclipse /usr/local/Eclipse4C

rm -rf eclipse-cpp-luna-R-linux-gtk-x86_64.tar.gz

3. 创建桌面快捷方式

在系统桌面上单击右键,在弹出菜单中选择“Create Launcher ...”,按照如下截图进行设置:

其中,Command参数为/usr/local/Eclipse4C/eclipse,点击OK按钮便可在桌面创建快捷方式

4. 设置Workspace

mkdir -p /home/Workspace/C

在桌面上双击打开Eclipse4C快捷方式,将Workspace目录指定为/home/Workspace/C,如下图所示:

5. 安装ShellED插件

在Eclipse的菜单栏上找到Help → Install New Software ...,打开Install窗口,配置好之后,如下图所示:

勾选Shell Script之后,一路Next下去即可

ShellED的下载链接为:http://sourceforge.net/projects/shelled/files/shelled/update/

6. 为C/C++工程添加ShellED支持

右键点击工程名称,在弹出的菜单中选择ShellED → Add Shell Script Support

经过如上设置,Eclipse便可以在C/C++工程中运行Shell脚本了

GCC编译器入门  http://www.linuxidc.com/Linux/2015-01/111431.htm

Ubuntu 12.04嵌入式交叉编译环境arm-linux-GCC搭建过程图解 http://www.linuxidc.com/Linux/2013-06/85902.htm

Ubuntu 12.10安装交叉编译器arm-none-linux-gnueabi-GCC http://www.linuxidc.com/Linux/2013-03/82016.htm

Ubuntu下Vim+GCC+GDB安装及使用 http://www.linuxidc.com/Linux/2013-01/78159.htm

Ubuntu下两个GCC版本切换 http://www.linuxidc.com/Linux/2012-10/72284.htm

GCC 的详细介绍请点这里
GCC 的下载地址请点这里

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-01/112057.htm

原文地址:https://www.cnblogs.com/tangjiansheng/p/6509729.html