在ubuntu14.04環境下編譯gcc

  1. 到GNU開源網址下載gcc源碼,並查看編譯教程

    GNU/GCC網址:http://www.gnu.org/software/gcc/

    2.根據官網教程,編譯gcc的所需環境依賴m4,gmp,mfpr,mpc

        

  • GNU Multiple Precision Library (GMP) version 4.3.2 (or later)

  • Necessary to build GCC.  If a GMP source distribution is found in a subdirectory of your GCC sources named gmp, it will be built together with GCC.  Alternatively, if GMP is already installed but it is not in your library search path, you will have to configure with the--with-gmp configure option.  See also --with-gmp-liband --with-gmp-include.    

  • MPFR Library version 2.4.2 (or later)

  • Necessary to build GCC.  It can be downloaded fromhttp://www.mpfr.org/.  If an MPFR source distribution is found in a subdirectory of your GCC sources named mpfr, it will be built together with GCC.  Alternatively, if MPFR is already installed but it is not in your default library search path, the--with-mpfr configure option should be used.  See also--with-mpfr-lib and --with-mpfr-include.    

  • MPC Library version 0.8.1 (or later)

  • Necessary to build GCC.  It can be downloaded fromhttp://www.multiprecision.org/.  If an MPC source distribution is found in a subdirectory of your GCC sources named mpc, it will be built together with GCC.  Alternatively, if MPC is already installed but it is not in your default library search path, the--with-mpc configure option should be used.  See also--with-mpc-lib and --with-mpc-include.

                                                                        --------來自https://gcc.gnu.org/install/prerequisites.html

    3.以上一個依賴包,也是GNU項目,可從GNU網站找到

            http://www.gnu.org/software/m4/

            http://www.gnu.org/software/gmp/

            http://www.gnu.org/software/mpfr/

           http://www.gnu.org/software/mpc/

     4.按順序依次

                解壓

                        tar xjf XXX.tar.bz2

                ./configure

                make

                sudo make install

      5.編譯gcc

                解壓gcc源碼

                創建gcc-build

                ../gcc-5.3.0/configure

                設置環境變量     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

                make

                sudo make install

       6.成功

                /usr/local/bin/gcc -v

         

       7.遇到問題:

                問題1:  cannot compute suffix of object files: cannot compile

                        配置環境變量,或者路徑不對

                       解決: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章