GCC Manual Build

本文档详细介绍了如何从源代码手动安装GCC-GNU编译器。步骤包括:1) 通过Git克隆源代码;2) 安装必要的依赖库如GMP, MPFR, MPC和ISL;3) 手动编译并安装这些库;4) 配置和安装GCC;5) 设置环境变量;6) 使用手动安装的GCC进行编译工作。这适用于需要自定义GCC配置或系统未提供预编译包的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Goto Installing GCC- GNU Project it describes the generic installation procedure.

1. Retrieve source code GCC: Anonymous read-only Git access- GNU Project 

        git clone git://gcc.gnu.org/git/gcc.git srcdir

        OR

         git clone https://gcc.gnu.org/git/gcc.git srcdir

2. Prerequisites   Downloading GCC- GNU Project 

        Go to srcdir, run contrib/download_prerequisites.

3. Download GMP, MPFR and/or MPC and/or isl.

        apt-get install libgmp-dev libmpfr-dev libmpc-dev

        OR 
        Download the package and build manually, go to Index of /pub/gcc/infrastructure . 

4. Manual install GMP, MPFR and/or MPC and/or isl 

  • Download gmp-6.2.1.tar.xz  The GNU MP Bignum Library
    • tar xvf gmp-6.2.1.tar.xz
    • ./configure --prefix=/usr/local/gmp
    • make -j8 && make install
  • Download mpfr-4.1.0.tar.xz Index of /gnu/mpfr
    • tar xvf mpfr-4.1.0.tar.xz
    •  ./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
    • make -j8 && make install
  • Download mpc-1.2.1.tar.gz Index of /gnu/mpc
    • tar xvf mpc-1.2.1.tar.gz
    • ./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr/ 
    • make -j8 && make install
  • Download isl-0.24.tar.bz2 https://gcc.gnu.org/pub/gcc/infrastructure/ 
    • tar xvf isl-1.2.1.tar.gz
    • ./configure --prefix=/usr/local/isl --with-gmp-prefix=/usr/local/gmp/
    • make -j8 && make install

5. If 4, export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/isl/lib:/usr/local/gmp:/usr/local/mpfr:/usr/local/mpc

6. Install flex, apt-get install flex.

7. Configure GCC:

  • % mkdir objdir
  • % cd objdir
  • % srcdir/configure --disable-multilib --prefix=$srcdir/install

    Any configure error, go to objdir/Config.log.

You can specify the path 

--with-gmp=pathname

--with-gmp-include=pathname

--with-gmp-lib=pathname

--with-mpfr=pathname

--with-mpfr-include=pathname

--with-mpfr-lib=pathname

--with-mpc=pathname

--with-mpc-include=pathname

--with-mpc-lib=pathname

8. make -j`nproc` && make install

It install the gcc to $srcdir/install which is set in gcc configuration.

9. Use the manual gcc

export CC=$srcdir/install/gcc
export CXX=$srcdir/install/g++

10. Now, run cmake /path/to/your/project, it uses this manual build.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值