linux編譯gcc-5.1.0

來源:互聯網
上載者:User

標籤:gcc   下載   編譯   依賴   

最新的gcc-5.1.0才發布出來,迫不及待地裝上試一試。
在http://ftp.gnu.org/gnu/gcc/下載gcc-5.1.0
然後解壓到目錄gcc-5.1.0/
運行

    ./contrib/download_prerequisites 

下載編譯所需的依賴包
gcc依賴包有:m4-1.4.17.tar.gz,gmp-5.1.3.tar.gz mpfr-3.1.2.tar.gz mpc-1.0.3.tar.gz
但是這些包都太新了,這些依賴包太新了也不行,太舊了也不行,只能使用合適的版本,這樣使用gcc內建的下載依賴的方式最好不過了。
然後在gcc-5.1.0/ 的同一級目錄下面

mkdir gcc-build/cd gcc-build../gcc-5.1.0/configure --build=x86_64-linux-gnu --prefix=/usr/local/lib/gcc-5.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib

執行完configure之後產生了Makefile檔案,然後:

make

如果你的電腦有4核CPU的話可以直接make -j4

make install

好啦,現在在你的/usr/local/lib/下有個gcc-5.1.0的目錄了,這個目錄就是gcc-5.1.0的安裝目錄。只要把/usr/local/lib/gcc-5.1.0/bin加入到PATH中就行了。

如果嫌上述安裝步驟太繁瑣就直接使用我寫的指令碼:
github上的gcc-install.sh指令碼
如果指令碼下載gcc-5.1.0很慢的話(被牆了),那麼可以先下載gcc-5.1.0.tar.gz到指令碼同一層級目錄,然後執行指令碼

我們來看看依賴庫如果太新會怎麼樣:
以下是錯誤的安裝方法:—————————————-
先下載m4-1.4.17.tar.gz,gmp-5.1.3.tar.gz mpfr-3.1.2.tar.gz mpc-1.0.3.tar.gz
全部解壓到/root目錄下然後:
安裝m4:——————————-

cd m4-1.4.17./configure --prefix=/usr/local/lib/m4-1.4.17make make checkmake install

安裝gmp:————————————

cd gmp-5.1.3./configure --prefix=/usr/local/lib/gmp-5.1.3makemake checkmake install

安裝mpfr:———————————————

cd mpfr-3.1.2./configure --prefix=/usr/local/lib/mpfr-3.1.2  --with-gmp=/usr/local/lib/gmp-5.1.2makemake checkmake clean

安裝mpc:———————————————-

cd mpc-1.0.3./configure --prefix=/usr/local/lib/mpc-1.0.3   --with-gmp=/usr/local/lib/gmp-5.1.3 --with-mpfr=/usr/local/lib/mpfr-3.1.2makemake checkmake install

安裝gcc:———————————————————-

cd  gcc-build/../gcc-5.1.0/configure --build=x86_64-linux-gnu --prefix=/usr/local/lib/gcc-5.1.0 --with-gmp=/usr/local/lib/gmp-5.1.3 --with-mpfr=/usr/local/lib/mpfr-3.1.2 --with-mpc=/usr/local/lib/mpc-1.0.3 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilibmake -j4

出錯了:
configure: error: in `/root/gcc-5.1.0/x86_64-unknown-linux-gnu/libgcc’: configure: error: cannot compute suffix of object files: cannot compile
前功盡棄,還是老老實實按照前面的方法安裝吧

linux編譯gcc-5.1.0

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.