在ubuntu14.04环境下编译gcc

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在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

以上是关于在ubuntu14.04环境下编译gcc的主要内容,如果未能解决你的问题,请参考以下文章

关于在ubuntu14.04下编译安装ffmpeg

Linux 下编译openjdk

Ubuntu12下编译安装PHP5.3开发环境

如何在32位ubuntu11.10 下编译android 4.0.1源码和goldfish内核

ubuntu环境下编译bitcoin(比特币)全过程

在没有 AVX 的情况下编译 boost