# Compile GCC 4.8.2 in Ubuntu-x64bit
# Install necessary software packages
Sudo apt-get update
Sudo apt-get install gcc
Sudo apt-get install g ++
Sudo apt-get install gawk
Sudo apt-get instll m4
Sudo apt-get install gcc-multilib
Sudo apt-get install binutils
Sudo apt-get install lzip
# Creating a GCC directory
Cd ~
Mkdir GCC & cd GCC
# Download GCC-4.8.2 source code: http://gcc.gnu.org/mirrors.html
# Download three required libraries: gmp, mpfr, and nm5. depending on the dependency: mpfr depends on gmp, and nmpa depends on gmp and mpfr.
# First install gmp, then install mpfr, then install mcm, and finally install gcc
# Gmp: https://gmplib.org/
# Mpfr: http://www.mpfr.org/mpfr-current/#download
# MCM: http://www.multiprecision.org/index.php? Prog = mpc & page = download
#
# Gmp
Wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.lz
# Mpfr
Wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.xz
# Mpc
Wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
# Gcc-4.8.2
Wget http://mirrors.webhostinggeeks.com/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2
# Decompress gmp
Lzip-d gmp-5.1.3.tar.lz
Tar-xvf gmp-5.1.3.tar-C gmp
# Decompress mpfr
Tar-Jxvf mpfr-3.1.2.tar.xz-C mpfr
# Extract the mpc
Tar-zxvf mpc-1.0.2.tar.gz-C mpc
# Decompress GCC
Tar-jxvf gcc-4.8.2.tar.bz2-C gcc
###############
# Start compilation #
###############
# Compile the gmp library, install it to the/usr/gcc_4_8 directory, with the x86_64-linux-gnu Kernel
Cd gmp
Mkdir build & cd build
../Configure -- prefix =/usr/gcc_4_8 -- build = x86_64-linux-gnu
Make
Sudo make install
# Compile mpfr library, install to/usr/gcc_4_8 directory, with x86_64-linux-gnu kernel, with gmp Library
Cd ..
Cd ..
Cd mpfr
Mkdir build & cd build
../Configure -- build = x86_64-linux-gnu -- prefix =/usr/gcc_4_8 -- with-gmp =/usr/gcc_4_8
Make
Sudo make install
# Compile the mpc library, depending on gmp, mpfr, and kernel...
Cd ..
Cd ..
Cd MCM
Mkdir build & cd build
../Configure -- build = x86_64-linux-gnu -- prefix =/usr/gcc_4_8 -- with-gmp =/usr/gcc_4_8 -- with-mpfr =/usr/gcc_4_8
Make
Sudo make install
#####################
# Prepare the GCC source code #
#####################
# Compile the C/C ++ and Fortran compilers.
Cd ..
Cd ..
Mkdir build & cd build
Export LIBRARY_PATH =/usr/lib/x86_64-linux-gnu/
Export C_INCLUDE_PATH =/usr/include/x86_64-linux-gnu
Export CPLUS_INCLUDE_PATH =/usr/include/x86_64-linux-gnu
.. /Gcc/configure -- build = x86_64-linux-gnu -- prefix =/usr/gcc_4_8 -- with-gmp =/usr/gcc_4_8 -- with-mpfr =/usr/gcc_4_8 -- with-mpc =/usr /gcc_4_8 -- enable-checking = release -- enable-ages = c, c ++ and fortran -- disable-multilib -- program-suffix =-4.8
Make
Sudo ln-s/usr/lib/x86_64-linux-gnu/usr/lib64
Sudo make install
######################################## ##
# Now, Gcc has been installed. Configure the system path below #
######################################## ##
# The following command can be used to add gcc 4.8 to the system path, or directly edit the. bashrc file in the home directory, and add the following line at the end
Export PATH =/usr/gcc_4_8/bin: $ PATH
# Simple Method for calling the Compiler
G ++-4.8 test. cpp-o test
# Delete source code
# Rm-rf gmp mpfr MCM gcc
# Other materials:
Before configuring the configuration, let's first explain the meaning of the configuration to be used:
-- Target = the generated target system # You do not need to configure this for compiling hosts.
-- Build = type of the compiled machine # This can be said to have to be modified
-- Host = host type # this parameter is not required
-- Prefix = installed directory # This must be configured
-- Enable-languages ages = This is the program generated by the configuration. Which language of the compiler is supported? # This configuration is required to prevent many files from being generated. Too many parameters cause compilation failure
-- Disable-werror: this is a close reminder # Not necessarily required.
-- Enable-ld = [yes, no] this is used in binutils compilation. # If you only compile this GCC, this can be omitted.
-- Enable-gold = [yes, no] this is used in binutils compilation. # This is not required only for compiling GCC.
-- Program-suffix = This is the post-Order of the program # to distinguish it from the built-in gcc, we recommend that you add this
-- Program-transform-name = This is used to generate personalized gcc naming rules. # If you use this option, you do not need the -- program-suffix option above.
-- Disable-multilib disable cross-platform libraries # use this option for Building