最近拿了台新機子安裝linux環境,安裝了ubantu較高版本,誰知道gcc版本太高導致編譯不通過,無奈之下只有降級gcc
當前的GCC版本為GCC-4.6,需要切換到GCC-4.2。首先,你需要去你的usr/bin/下去看看有沒有gcc-4.5這樣文件,如果沒有的話,就安裝一下吧: 我這里還必須要求是4.2.2囧
稍微搜了一下,下載了gcc4.2.2版本,然后按照正常流程./configure make.
在make的時候出現了cc 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,mpfr和mpc三個庫
安裝gmp和mpfr我是直接到解壓后然后放到gcc的目錄里面然后改名為gmp和mpfr即可,我下的這兩個包得版本是 gmp-5.0.2.tar.bz2 mpfr-3.1.tar.bz2
安裝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
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
之后就是慢慢等了。。。
完了之后給gcc作個軟連接
rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.2.2 /usr/bin/gcc