How to Manually Build GNU Compiler Collection from Scratch on Linux Mint Static Edition

In order to complete the build for the GNU Compiler Collection, we are going to need the following libraries and packages: GMP, MPFR, MPC, ELF and GCC., Put the downloads in a temp directory ( you can use whatever directory you want ) for example...

16 Steps 2 min read Advanced

Step-by-Step Guide

  1. Step 1: In order to complete the build for the GNU Compiler Collection

    I use
    --disable-shared because I am building static code only, and I want to make sure that I don't build any shared code.

    My need is to move the resulting GCC around my drives easily, so I want all static code, and I do not want any shared code.

    If you prefer shared code, omit the
    --disable-shared flag. , You will need to make sure you have a C/C++ compiler already installed in order to build the gcc Type/Copy/Paste: sudo apt-get install g++ ,, It depends on GMP Type/Copy/Paste: wget
    -c Type/Copy/Paste: chmod a+x mpfr-3.1.2.tar.bz2 Type/Copy/Paste: tar jxvf mpfr-3.1.2.tar.bz2 Type/Copy/Paste: cd mpfr-3.1.2 Type/Copy/Paste: ./configure
    --disable-shared
    --enable-static
    --prefix=/tmp/gcc
    --with-gmp=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. , It depends on GMP and MPFR Type/Copy/Paste: wget
    -c http://multiprecision.org/mpc/download/mpc-1.0.1.tar.gz Type/Copy/Paste: chmod a+x mpc-1.0.1.tar.gz Type/Copy/Paste: tar zxvf mpc-1.0.1.tar.gz Type/Copy/Paste: cd mpc-1.0.1 Type/Copy/Paste: ./configure
    --disable-shared
    --enable-static
    --prefix=/tmp/gcc
    --with-gmp=/tmp/gcc
    --with-mpfr=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. , This library takes and provides architecture-independent size and endian support Type/Copy/Paste: wget
    -c http://www.mr511.de/software/libelf-0.8.13.tar.gz Type/Copy/Paste: chmod a+x libelf-0.8.13.tar.gz Type/Copy/Paste: tar zxvf libelf-0.8.13.tar.gz Type/Copy/Paste: cd libelf-0.8.13 Type/Copy/Paste: ./configure
    --disable-shared
    --enable-static
    --prefix=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. ,, (Building it within /tmp would trigger cross compile host issues) Type/Copy/Paste: mkdir
    -p gcc481_build Type/Copy/Paste: cd gcc481_build Type/Copy/Paste: ../gcc-4.8.1/configure
    --disable-shared
    --disable-bootstrap
    --disable-libstdcxx-pch
    --enable-libgomp
    --enable-lto
    --enable-threads=posix
    --enable-tls
    --with-fpmath=sse
    --prefix=/tmp/gcc
    --with-gmp=/tmp/gcc
    --with-mpfr=/tmp/gcc
    --with-mpc=/tmp/gcc
    --with-libelf=/tmp/gcc
    --with-fpmath=sse
    --disable-multilib
    --enable-languages=c,c++ Type/Copy/Paste: make && make install , Type/Copy/Paste: cd /tmp Type/Copy/Paste: mv gcc /home/your_username/
  2. Step 2: we are going to need the following libraries and packages: GMP

  3. Step 3: ELF and GCC.

  4. Step 4: Put the downloads in a temp directory ( you can use whatever directory you want ) for example

  5. Step 5: /home/”your_username”/gcc_archive Build the infrastructure in a temp directory that is different than the downloads directory or its sub directories: /tmp/gcc Configure the infrastructure using static libraries like this: ./configure --disable-shared --enable-static --prefix=/tmp/gcc The --disable-shared flag may be worth a closer look depending on your needs.

  6. Step 6: Open up a terminal and enter the following command: Type/Copy/Paste: mkdir gcc_archive Download and place all GMP

  7. Step 7: ELF and GCC packages in this directory Type/Copy/Paste: sudo apt-get install binutils build-essential m4 autogen bison flex You will need to add these packages in order to set up a proper build environment.

  8. Step 8: Install GMP - is the GNU Multiple Precision Arithmetic Library Type/Copy/Paste: cd gcc_archive Type/Copy/Paste: wget -c ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2 Type/Copy/Paste: chmod a+x gmp-5.1.3.tar.bz2 Type/Copy/Paste: tar jxvf gmp-5.1.3.tar.bz2 Type/Copy/Paste: cd gmp-5.1.1 Type/Copy/Paste: ./configure --disable-shared --enable-static --prefix=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd ..

  9. Step 9: Install MPFR - is the GNU Multiple-precision floating-point rounding library.

  10. Step 10: Install MPC - is the GNU Multiple-precision C library.

  11. Step 11: Install ELF - stands for Executable and Linkable Format.

  12. Step 12: Install GCC - is the GNU Compiler Collection It depends on GMP

  13. Step 13: and ELF Type/Copy/Paste: wget -c http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2 Type/Copy/Paste: chmod a+x gcc-4.8.1.tar.gz Type/Copy/Paste: tar zxvf gcc-4.8.1.tar.gz

  14. Step 14: Notes: Build gcc in a scratch directory on the same mount point.

  15. Step 15: When everything is complete building the new portable GNU GCC will be located in /tmp/gcc

  16. Step 16: just change into your /tmp directory and move your new portable GNU GCC to /home/"your_username"/ directory.

Detailed Guide

I use
--disable-shared because I am building static code only, and I want to make sure that I don't build any shared code.

My need is to move the resulting GCC around my drives easily, so I want all static code, and I do not want any shared code.

If you prefer shared code, omit the
--disable-shared flag. , You will need to make sure you have a C/C++ compiler already installed in order to build the gcc Type/Copy/Paste: sudo apt-get install g++ ,, It depends on GMP Type/Copy/Paste: wget
-c Type/Copy/Paste: chmod a+x mpfr-3.1.2.tar.bz2 Type/Copy/Paste: tar jxvf mpfr-3.1.2.tar.bz2 Type/Copy/Paste: cd mpfr-3.1.2 Type/Copy/Paste: ./configure
--disable-shared
--enable-static
--prefix=/tmp/gcc
--with-gmp=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. , It depends on GMP and MPFR Type/Copy/Paste: wget
-c http://multiprecision.org/mpc/download/mpc-1.0.1.tar.gz Type/Copy/Paste: chmod a+x mpc-1.0.1.tar.gz Type/Copy/Paste: tar zxvf mpc-1.0.1.tar.gz Type/Copy/Paste: cd mpc-1.0.1 Type/Copy/Paste: ./configure
--disable-shared
--enable-static
--prefix=/tmp/gcc
--with-gmp=/tmp/gcc
--with-mpfr=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. , This library takes and provides architecture-independent size and endian support Type/Copy/Paste: wget
-c http://www.mr511.de/software/libelf-0.8.13.tar.gz Type/Copy/Paste: chmod a+x libelf-0.8.13.tar.gz Type/Copy/Paste: tar zxvf libelf-0.8.13.tar.gz Type/Copy/Paste: cd libelf-0.8.13 Type/Copy/Paste: ./configure
--disable-shared
--enable-static
--prefix=/tmp/gcc Type/Copy/Paste: make && make check && make install Type/Copy/Paste: cd .. ,, (Building it within /tmp would trigger cross compile host issues) Type/Copy/Paste: mkdir
-p gcc481_build Type/Copy/Paste: cd gcc481_build Type/Copy/Paste: ../gcc-4.8.1/configure
--disable-shared
--disable-bootstrap
--disable-libstdcxx-pch
--enable-libgomp
--enable-lto
--enable-threads=posix
--enable-tls
--with-fpmath=sse
--prefix=/tmp/gcc
--with-gmp=/tmp/gcc
--with-mpfr=/tmp/gcc
--with-mpc=/tmp/gcc
--with-libelf=/tmp/gcc
--with-fpmath=sse
--disable-multilib
--enable-languages=c,c++ Type/Copy/Paste: make && make install , Type/Copy/Paste: cd /tmp Type/Copy/Paste: mv gcc /home/your_username/

About the Author

E

Emily Watson

Enthusiastic about teaching home improvement techniques through clear, step-by-step guides.

38 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: