The gcc version that comes with CentOS6.5 is 4.4.7. in some times, some libraries are not used for new software, and the latest gcc4.8.2 has been released, so download the source code and install it. 1. first install the old gcc-related compilation tool yuminstallgccgcc-c ++ gl
The gcc version that comes with CentOS6.5 is 4.4.7. in some times, some libraries are not used for new software, and the latest gcc 4.8.2 has been released, so download the source code and install it.
1. first install the old gcc-related compilation tools
Yum install gcc-c ++ glibc-static-y
2. download gcc 4.8.2 source package, and its dependency on three source package gmp-4.3.2, mpfr-2.4.2, mpc-0.8.1
3. unzip and install the tool in the following sequence: gmp, mpfr, mpc, and gcc.
4. install gmp:
(1) decompress the package and enter the folder:
Tar-jxf gmp-4.3.2.tar.bz2
Cd gmp-4.3.2
(2) create a folder and enter it. This folder is used to store compiled files. if compilation fails, you can delete the folder and try again.
Mkdir gmp-build
Cd gmp-build
(3) follow the instructions in the gmp-4.3.2/INSTALL to complete the step one by one, -- prefix specifies the installation directory
../Configure -- prefix =/usr/local/gmp/
Make
Make check
Make install
5. install mpfr:
(1) decompress the package and enter the folder:
Tar-jxf mpfr-2.4.2.tar.bz2
Cd mpfr-2.4.2
(2) Follow the gmp method as follows:
Mkdir mpfr-build
Cd mpfr-build
(3) follow the instructions in the mpfr-2.4.2/INSTALL to complete the step one by one, -- prefix specifies the installation directory
../Configure -- prefix =/usr/local/mpfr/-- with-gmp =/usr/local/gmp
Make
Make check
Make install
6. install MCM:
(1) decompress the package and enter the folder:
Tar-zxvf mpc-0.8.1.tar.gz
Cd mpc-0.8.1
(2) Follow the gmp method as follows:
Mkdir mpc-build
Cd mpc-build
(3) follow the instructions in the mpc-0.8.1/INSTALL to complete the step one by one, -- prefix specifies the installation directory
../Configure -- prefix =/usr/local/mcm/-- with-gmp =/usr/local/gmp
-- With-gmp =/usr/local/mpfr
Make
Make check
Make install
7. add the shared library path, su to the root to edit the/etc/ld. so. conf file, and add the following content to the file:
/Usr/local/gmp/lib
/Usr/local/mpfr/lib
/Usr/local/mcm/lib
Save and exit. run the ldconfig command.
8. install gcc:
(1) decompress the package and enter the folder:
Tar-jxf gcc-4.8.2.tar.bz2
Cd gcc-4.8.2
(2) the method can be referred to before:
Mkdir gcc-build
Cd gcc-build
(3) compile and install, -- with-with the dependent package. This compilation takes a long time and requires patience.
../Configure -- prefix =/usr/local/gcc -- enable-threads = posix -- disable-checking -- enable-la
Nguages = c, c ++ -- disable-multilib -- with-gmp =/usr/local/gmp
-- With-gmp =/usr/local/mpfr -- with-gmp =/usr/local/MCM
Make & make install
9. uninstall gcc and g ++ of the old version on CentOS 6.5 and update the database at the same time.
Yum remove gcc
Yum remove gcc-c ++
Updatedb
10. link to the new version
Cd/usr/bin
Ln-s/usr/local/gcc/bin/gcc
Ln-s/usr/local/gcc/bin/g ++
11. Add man help and add the gcc man path to the configuration file/etc/man. config.
MANPATH/usr/local/gcc/share/man
Save and exit to take effect. you can use man gcc to view help
12. Complete. check the installed gcc version to see if it is 4.8.2.
Gcc-v