linux下安裝gcc

來源:互聯網
上載者:User

一、首先從GNU上下載GCC包,ftp://gcc.gnu.org/,我使用的是最新發行版本gcc-4.5.1.tat.gz,

1)  tar zxvf gcc-4.5.1.tar.gz

2)  cd gcc-4.5.1

3) ./congigure

此時會出現這樣的錯誤:
                        gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
        從錯誤中可以看出:GCC編譯需要GMP, MPFR, MPC這三個庫,我使用的版本為gmp-4.3.2,mpfr-2.4.2和mpc-0.8.1。這三個包從下面的地址下載:

http://gmplib.org/,http://www.mpfr.org/,http://www.multiprecision.org/

 
 二、安裝GMP時也出現了錯誤:
                              No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
        由此可以看出是缺少M4檔案。可以去這裡下載:http://ftp.gnu.org/gnu/m4/  。我這裡下載了m4-1.4.1.tar.gz  
1)  tar zxvf m4-1.4.1.tar.gz
2)  cd m4-1.4.1
3)  ./configure
4)  make
5)  make check(強烈建議檢查,確保正確)
6)  make install(需要root,建議在root中安裝)

三、有了M4就可以裝別的了。由於MPFR和MPC都依賴於GMP包,所以首先安裝GMP。
1)tar jxvf gmp-4.3.2.tar.bz2
2)cd gmp-4.3.2
3)./configure
4)make
5)make check
6)  make install

 

四、安裝MPFR
1)  tar jxvf mpfr-2.4.2.tar.bz2
2)  cd mpfr-2.4.2
3)  ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib
4)  make
5)  make check
6)  make install

五、安裝MPC

1)  tar zxvf mpc-0.8.1.tar.gz
2)  cd mpc-0.8.1
3)  ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib
4)  make
5) ldconfig -v(出現:error while loading shared libraries: libmpfr.so.1: cannot open shared objec,可以自己去man ldd 和ldconfig)
6) make check
7)  make install

六、這幾個庫的預設位置是/usr/local/include和/usr/local/lib,GCC編譯時間可能會找不到這三個庫,需要確認庫位置是否在環境變數LD_LIBRARY_PATH中,查看環境變數內容可以用命令
                $echo $LD_LIBRARY_PATH
        設定該環境變數命令如下:
                $export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
        現在開始安裝GCC
1) tar xvf gcc-4.5.1.tar.gz
2) cd gcc-4.5.1
3) ./configure
4) make
5) make check
6) sudo make install

經過較長時間(我等了近一個小時)等待就可以編譯完成。

 

 

 

相關文章

聯繫我們

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