但是安裝的過程中我發現竟然找不到gcc。於是我就去網上(gcc.gnu.org)下載了一個gcc准備安裝。但是此次安裝遇到了各種各樣的麻煩,而且我linux用得也不好,於是在安裝成功後把遇到的問題記錄下來。安裝方法見[Linux下GCC的安裝方法] http://www.linuxidc.com/Linux/2009-01/18242.htm 與 http://www.linuxidc.com/Linux/2008-05/13063.htm
1.安裝gcc,但是提示找不到gcc,進而無法安裝gcc。
下載完gcc後,用tar -xjf gcc-4.4.5.tar.bz2解壓到gcc-4.4.5目錄下
cd gcc-4.4.5後configure --prefix=/usr/local/gccobjdir錯誤出現了
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
安裝gcc時找不到gcc編譯環境。於是我進入/usr/bin目錄,ls | grep gcc查找一下gcc是否存在,看到了一個gcc264文件(後面具體多少記不清了)。懷疑該文件即gcc,於是cp gcc264 gcc,拷貝了一份再gcc -v查看版本信息,原來後面跟那個數字是版本。
然後重新執行configure --prefix=/usr/local/gccobjdir以上錯誤消失,但是新錯誤出現了
2.提示缺少gmp和mpfr庫。
繼續運行configure命令,提示如下:
gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
說明要安裝gcc需要GMP、MPFR、MPC這三個庫,可從ftp://gcc.gnu.org/pub/gcc/infrastructure/下載相應的壓縮包。由於MPFR依賴GMP,而MPC依賴GMP和MPFR,所以要先安裝GMP,其次MPFR,最後才是MPC。這裡三個庫我用的版本分別是gmp4.3.2,mpfr2.4.2和mpc0.8.1。
先開始安裝GMP。解壓GMP的壓縮包後,得到源代碼目錄gmp-4.3.2。在該目錄的同級目錄下建立一個臨時的編譯目錄,這裡命名為gmp-build。然後開始配置安裝選項,進入gmp-build目錄,輸入以下命令進行配置:
../gmp-4.3.2/configure --prefix=/usr/local/gmp-4.3.2
這裡--prefix選項代表要將該庫安裝在哪裡,我是裝在/usr/local/gmp-4.3.2目錄下,後面的安裝都會用到這個選項。
這時在gmp的編譯目錄下就會生成一個makefile文件,現在開始編譯安裝。
make
make check
sudo make install
這樣就安裝好了gmp。mpfr和mpc的安裝方法與此類似。不過要注意配置的時候要把依賴關系選項加進去,具體後面兩個庫配置命令如下:
../mpfr-2.4.2/configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
../mpc-0.8.1/configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
安裝完成這3個庫後,繼續運行configure --prefix=/usr/local/gccobjdir命令,終於可以配置gcc了。
3.配置好gcc後不能進行make編譯
配置完成後,輸入make命令,編譯源代碼,但是提示make版本太低,我make -v查看了一下版本為3.79,囧,再去下載個make吧(溫馨提示,使用google搜索代替百度搜可以直接搜索到下載地址)同樣
安裝 Make
為編譯 Make 做准備:
./configure --prefix=/usr
編譯軟件包:
make
安裝軟件包:
make install
make安裝完成後重新進入剛才執行configure命令的目錄,繼續make。此時便可以編譯成功。(編譯太慢了),等待中