How to Manually Build and Install GNU Compiler Collection on Linux Mint

Install required packages Type/Copy/Paste: sudo apt-get install binutils build-essential m4 autogen bison flex Type/Copy/Paste: sudo apt-get install g++ You will need these packages as part of a complete build environment., Open up a terminal and...

39 Steps 2 min read Advanced

Step-by-Step Guide

  1. Step 1: Install required packages Type/Copy/Paste: sudo apt-get install binutils build-essential m4 autogen bison flex Type/Copy/Paste: sudo apt-get install g++ You will need these packages as part of a complete build environment.

    So change into the directory.

    Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive , Type/Copy/Paste: wget
    -c ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2 Type/Copy/Paste: wget
    -c http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2 Type/Copy/Paste: wget
    -c http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz Type/Copy/Paste: wget
    -c http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2 ,,,, Since the GCC website did say that we should run configure command in another folder other than the source folder, we need to create another folder just for this (e.g. gcc481_build):
    Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive Type/Copy/Paste: sudo mkdir
    -p /opt/gcc-4.8.1 This will create the directory which will hold the new GNU Compiler Collection (GCC) Type/Copy/Paste: chmod a+x gcc-4.8.1.tar.bz2 Type/Copy/Paste: tar
    -jxvf gcc-4.8.1.tar.bz2 Type/Copy/Paste: mkdir gcc481_build This will create the scratch directory to build the GNU Compiler Collection (GCC) Type/Copy/Paste: cd gcc481_build Type/Copy/Paste: ../gcc-4.8.1/configure
    --prefix=/opt/gcc-4.8.1
    --with-gmp=/opt/gmp-5.1.3
    --with-mpfr=/opt/mpfr-3.1.2
    --with-mpc=/opt/mpc-1.0.1
    --disable-multilib
    --enable-languages=c,c++ ,, I would expect at least a 4 hour build/compile on most systems. ,,,,, /etc/profile ,, They should output the version of GCC you have just built (e.g.
    4.8.1) Type/Copy/Paste: gcc
    --version Type/Copy/Paste: g++
    --version ,,,,,
  2. Step 2: Open up a terminal and type the following: Type/Copy/Paste: mkdir /home/"your_user_name"/gcc_archive This will create a directory to hold your downloaded packages and compiled libraries

  3. Step 3: Download the following programs and place them in the gcc_archive directory You will download all your packages you need to compile GCC to the /home/"your_user_name_"/gcc_archive directory.

  4. Step 4: While in the /home/"your_user_name"/gcc_archive directory run the following commands.

  5. Step 5: Install GNU GMP Multiprecision Arithmetic Library

  6. Step 6: for arbitrary precision arithmetic: Go to ftp://ftp.gmplib.org/pub/ to download the latest version

  7. Step 7: then run these commands in the folder contains that file to extract

  8. Step 8: build and install GMP: Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive Type/Copy/Paste: sudo mkdir /opt/gmp-5.1.3 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.3 Type/Copy/Paste: ./configure --prefix=/opt/gmp-5.1.3 Type/Copy/Paste: make && make check && sudo make install Notes: It is recommended to run make check Type/Copy/Paste: cd ..

  9. Step 9: Install GNU MPFR Library

  10. Step 10: Multiple-Precision Floating-Point computations with correct rounding Go to http://www.mpfr.org/mpfr-current/ to download the latest version

  11. Step 11: then run these commands in the folder contains that file to extract

  12. Step 12: build and install MPFR: Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive Type/Copy/Paste: sudo mkdir /opt/mpfr-3.1.2 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 --prefix=/opt/mpfr-3.1.2 --with-gmp=/opt/gmp-5.1.3 Type/Copy/Paste: make && make check && sudo make install Notes: You must install GMP before installing MPFR Type/Copy/Paste: cd ..

  13. Step 13: Install GNU MPC Library

  14. Step 14: for arithmetic using complex numbers Go to http://www.multiprecision.org/index.php?prog=mpc&page=download to download the latest version

  15. Step 15: then run these commands in the folder contains that file to extract

  16. Step 16: build and install MPFR: Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive Type/Copy/Paste: sudo mkdir /opt/mpc-1.0.1 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 --prefix=/opt/mpc-1.0.1 --with-gmp=/opt/gmp-5.1.3 --with-mpfr=/opt/mpfr-3.1.2 Type/Copy/Paste: make && make check && sudo make install Notes: You must install GMP and MPFR before installing MPC Type/Copy/Paste: cd ..

  17. Step 17: Configure build options for GNU Compiler Collection (GCC) Download the the latest version of GCC from http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2 .

  18. Step 18: While in the gcc481_build directory

  19. Step 19: set some environment variables to prepare for the upcoming build 32-bit Linux Mint Instructions: Type/Copy/Paste: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gmp-5.1.2/lib:/opt/mpfr-3.1.2/lib:/opt/mpc-1.0.1/lib Type/Copy/Paste: export C_INCLUDE_PATH=/usr/include/i386-linux-gnu Type/Copy/Paste: export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH Type/Copy/Paste: export OBJC_INCLUDE_PATH=$C_INCLUDE_PATH Type/Copy/Paste: export LIBRARY_PATH=/usr/lib/i386-linux-gnu 64-bit Linux Mint Instructions: Type/Copy/Paste: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gmp-5.1.2/lib:/opt/mpfr-3.1.2/lib:/opt/mpc-1.0.1/lib Type/Copy/Paste: export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu Type/Copy/Paste: export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH Type/Copy/Paste: export OBJC_INCLUDE_PATH=$C_INCLUDE_PATH Type/Copy/Paste: export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

  20. Step 20: Build and install GNU Compiler Collection (GCC) Type/Copy/Paste: make -j 4 Type/Copy/Paste: sudo make install Notes: Be prepared for a long build -- it usually takes anywhere from 2 to 4 hours for a complete build

  21. Step 21: however it all depends on the speed of your processor.

  22. Step 22: Modify your system-wide environment variables to support new version of GNU Compiler Collection (GCC) Since there is no default .bashrc file for users on Linux Mint

  23. Step 23: you do not need to add the PATH to the new GCC to such a file Type/Copy/Paste: sudo nano /etc/profile

  24. Step 24: Then add the following lines to the end of /etc/profile

  25. Step 25: then save and close it: 32-bit Linux Mint Instructions: Type/Copy/Paste: export PATH=/opt/gcc-4.8.1/bin:$PATH Type/Copy/Paste: export LIBRARY_PATH=/usr/lib/i386-linux-gnu 64-bit Linux Mint Instructions: Type/Copy/Paste: export PATH=/opt/gcc-4.8.1/bin:$PATH Type/Copy/Paste: export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

  26. Step 26: Use a text editor such as nano or gedit and add 3 lines to your /etc/ld.so.conf Type/Copy/Paste: sudo nano /etc/ld.so.conf Type/Copy/Paste: /opt/gmp-5.1.2/lib Type/Copy/Paste: /opt/mpfr-3.1.2/lib Type/Copy/Paste: /opt/mpc-1.0.1/lib

  27. Step 27: Run the command: Type/Copy/Paste: sudo ldconfig -v This will reload update your /etc/ld.so.conf file

  28. Step 28: Update the environment variables in your open terminal by running the following command Type/Copy/Paste: .

  29. Step 29: Verify your terminal's PATH environment variable by issuing the following command: Type/Copy/Paste: printenv PATH This should show /opt/gcc-4.8.1/bin is now at the front of your PATH

  30. Step 30: Finally

  31. Step 31: run below commands to check the gcc version.

  32. Step 32: After these steps are complete without error

  33. Step 33: reboot your Linux Mint operating system and then your system will configured properly for compiling GNU C/C++ programs on your Linux Mint system.

  34. Step 34: Later still

  35. Step 35: after you have confirmed that the new version is working fine you will probably want to delete the contents of /home/"your_user_name"/gcc_archive to reclaim space.

  36. Step 36: Also to build a truly portable GNU GCC Compiler

  37. Step 37: one that is transferable between different GNU/Linux Mint systems see the following article Manually-Build-GNU-Compiler-Collection-from-Scratch-on-Linux-Mint-Static-Edition Good Luck and as Richard Stallman likes to say "Happy Hacking !"

  38. Step 38: Location for sources: ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2 http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2 http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2

  39. Step 39: Location of the GCC infrastructure: ftp://gcc.gnu.org/pub/gcc/infrastructure/

Detailed Guide

So change into the directory.

Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive , Type/Copy/Paste: wget
-c ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2 Type/Copy/Paste: wget
-c http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2 Type/Copy/Paste: wget
-c http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz Type/Copy/Paste: wget
-c http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2 ,,,, Since the GCC website did say that we should run configure command in another folder other than the source folder, we need to create another folder just for this (e.g. gcc481_build):
Type/Copy/Paste: cd /home/"your_user_name"/gcc_archive Type/Copy/Paste: sudo mkdir
-p /opt/gcc-4.8.1 This will create the directory which will hold the new GNU Compiler Collection (GCC) Type/Copy/Paste: chmod a+x gcc-4.8.1.tar.bz2 Type/Copy/Paste: tar
-jxvf gcc-4.8.1.tar.bz2 Type/Copy/Paste: mkdir gcc481_build This will create the scratch directory to build the GNU Compiler Collection (GCC) Type/Copy/Paste: cd gcc481_build Type/Copy/Paste: ../gcc-4.8.1/configure
--prefix=/opt/gcc-4.8.1
--with-gmp=/opt/gmp-5.1.3
--with-mpfr=/opt/mpfr-3.1.2
--with-mpc=/opt/mpc-1.0.1
--disable-multilib
--enable-languages=c,c++ ,, I would expect at least a 4 hour build/compile on most systems. ,,,,, /etc/profile ,, They should output the version of GCC you have just built (e.g.
4.8.1) Type/Copy/Paste: gcc
--version Type/Copy/Paste: g++
--version ,,,,,

About the Author

J

Joshua Myers

Enthusiastic about teaching pet care techniques through clear, step-by-step guides.

31 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: