由於編譯源碼軟件需要在Ubuntu 14.04 LST用到gcc4.1.2版本,但是本機已經安裝有gcc4.8.4,下載gcc4.1.2源碼編譯總會出現運行找不到庫文件錯誤,或者i386和x86_64不兼容問題,網上都有相似問題的解答,最終安裝成功。
1. 下載&解壓源碼
$ wget http://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2 $ tar xvjf gcc-4.1.2.tar.bz2
2. 安裝依賴庫, 以及軟件
$ sudo apt-get install libc6-dev libgmp-dev libmpfr-dev texinfo
3. 為頭文件以及所需庫添加鏈接
添加如下鏈接, 這取決於你的 Ubuntu 系統架構, 如果你使用的是64位的ubuntu系統應當使用x86_64-linux-gnu
替代i386-linux-gnu
$ cd /usr/include $ sudo ln -s i386-linux-gnu/bits bits $ sudo ln -s i386-linux-gnu/gnu gnu $ sudo ln -s i386-linux-gnu/sys sys $ sudo ln -s i386-linux-gnu/asm asm $ cd /usr/lib $ sudo ln -s i386-linux-gnu/crt1.o crt1.o $ sudo ln -s i386-linux-gnu/crti.o crti.o $ sudo ln -s i386-linux-gnu/crtn.o crtn.o
4. 編譯gcc
$ cd gcc-4.1.2 $ mkdir build $ cd build $ ../configure --prefix=/usr/local --program-prefix=sse- --libexecdir=/usr/local/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --enable-languages=c,c++ $ make bootstrap
如果出現了如下錯誤:
WARNING: `makeinfo’ is missing on your system. You should only need it
if you modified a `.texi’ or `.texinfo’ file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy `make’ (AIX,
DU, IRIX). You might want to install the `Texinfo’ package or
the `GNU make’ package. Grab either from any GNU archive site.
請使用以下命令編譯:
$ make bootstrap MAKEINFO=makeinfo
5. 安裝gcc
$ make install $ cd /usr/local/bin $ ll *gcc*
看到類似以下幾個文件, 安裝就完成了
i686-pc-linux-gnu-gcc-4.1.2 i686-pc-linux-gnu-ssegcc ssegcc ssegccbug
Linux升級GCC 4.8.1清晰簡明教程(Ubuntu 12.04 64位版為例) http://www.linuxidc.com/Linux/2014-04/99583.htm
Ubuntu下Vim+GCC+GDB安裝及使用 http://www.linuxidc.com/Linux/2013-01/78159.htm
Ubuntu下兩個GCC版本切換 http://www.linuxidc.com/Linux/2012-10/72284.htm
CentOS6.5升級手動安裝GCC4.8.2 http://www.linuxidc.com/Linux/2015-01/112595.htm
GCC 的詳細介紹:請點這裡