How to upgrade GCC to 6.3.0 on CentOS, centos6.3.0
Virtual Machine Environment Information:
[Root @ localhost/] # cat/etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[Root @ localhost/] # cat/proc/version
Linux version 3.10.0-514. el7.x86 _ 64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) #1 SMP Tue Nov 22 16:42:41 UTC 2016
The gcc version is 4.8.5.
GCC depends on gmp4.2 +, mpfr2.4 +, and mpc0.8 +. download and install the latest version.
Install gmp6.1.2
Tarxvfgmp-6.1.2.tar.xz
Cdgmp-6.1.2
./Configure -- prefix =/usr/local/gmp
Make-j20 & makeinstall
(When you execute./configure -- prefix =/usr/local/gmp, the following error occurs: configure: error: cocould not find a working compiler. Directly uninstall yum remove gcc and then reinstall yum install gcc)
Installing mpfr3.1.5mpfr depends on gmp
Tarxvfmpfr-3.1.5.tar.gz
Cdmpfr-3.1.5
./Configure -- prefix =/usr/local/mpfr -- with-gmp =/usr/local/gmp
Make-j20 & makeinstall
The installation of mpc1.0.3nmdepends on gmp and mpfr.
Tarxvfmpc-1.0.3.tar.gz
Cdmpc-1.0.3
./Configure -- prefix =/usr/local/MCM -- with-gmp =/usr/local/gmp-with-mpfr =/usr/local/mpfr
Make-j20 & makeinstall
Install GCC6.3.0
Tarxvfgcc-6.3.0.tar.gz
Cdgcc-6.3.0
. /Configure -- prefix =/usr/local/gcc -- enable-threads = posix -- disable-checking -- disable-multilib -- enable-versions ages = c, c ++ -- with-gmp =/usr/local/gmp -- with-mpfr =/usr/local/mpfr -- with-mpc =/usr/local/MCM
Make-j20 & makeinstall
The following may occur during installation:
"Checkingforsuffixofobjectfiles... configure: error: cannotcomputesuffixofobjectfiles: cannotcompile
See 'config. log' formoredetails.
Make [2]: *** [configure-stage1-target-libgcc] Error1
Make [2]: Leavingdirectory '/tmp/gcc-6.3.0'
Make [1]: *** [stage1-bubble] Error2
Make [1]: Leavingdirectory '/tmp/gcc-6.3.0'
Make: *** [bootstrap] Error2
Solution:
Yuminstallm4
Yuminstallgcc-c ++
Practical Solution: edit the variables and add the installed gmp, mpfr, and nmpcs.
Vi/etc/ld. so. conf
Add part:
/Usr/local/lib # This is the default system variable.
/Usr/local/gmp/lib
/Usr/local/mpfr/lib
/Usr/local/mcm/lib
After adding and saving, remember to update the cache of the dynamic library:
Ldconfig-v
After the update, re-compile and install it.
Default gcc version of the Backup System
Mv/usr/bin/gcc-bak
Mv/usr/bin/g ++-bak
Mv/usr/bin/c ++-bak
Create a new gcc soft connection
Ln-sf/usr/local/gcc/bin/gcc/usr/bin/gcc
Ln-sf/usr/local/gcc/bin/c ++/usr/bin/c ++
Ln-sf/usr/local/gcc/bin/g ++/usr/bin/g ++
Ln-sf/usr/local/gcc/lib64/libstdc ++. so.6.0.22/usr/lib64/libstdc ++. so.6
View the gcc version:
[Root @ localhost ~] # Gcc -- version
Gcc (GCC) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
Warranty; not even for MERCHANTABILITY or fitness for a particle PURPOSE.
Or
[Root @ localhost ~] # Gcc-v
Using built-in specs.
COLLECT_GCC = gcc
COLLECT_LTO_WRAPPER =/usr/local/gcc/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured :. /configure -- prefix =/usr/local/gcc -- enable-threads = posix -- disable-checking -- disable-multilib -- enable-versions ages = c, c ++ -- with-gmp =/usr/local/gmp -- with-mpfr =/usr/local/mpfr -- with-mpc =/usr/local/MCM
Thread model: posix
Gcc version 6.3.0 (GCC)