在CentOS 6.4中編譯安裝GCC 4.8.1 + GDB 7.6.1 node
1、編譯安裝gcc 4.8.1linux
1. 安裝gcc和g++c++
新安裝的CentOS缺乏編譯環境,必須先安裝舊版本的gcc, 而後再進行自舉編譯ide
yum -y install gcc
yum -y install gcc-c++ui
2. 下載gcc 4.8.1源碼包spa
http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.gzorm
將源碼包放在home目錄的Download目錄中文檔
3. 解壓縮gcc 4.8.1源碼包get
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.
2、編譯安裝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