【轉】在CentOS 6.4中編譯安裝GCC 4.8.1 + GDB 7.6.1

來源:互聯網
上載者:User

標籤:

在CentOS 6.4中編譯安裝GCC 4.8.1 + GDB 7.6.1 

一、編譯安裝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


【轉】在CentOS 6.4中編譯安裝GCC 4.8.1 + GDB 7.6.1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.