Copyright statement: This article is the original article of the blogger, please indicate the source address for reprinting. https://blog.csdn.net/10km/article/details/78893983
If the system has not installed gcc, g++ compiler (4.4.7), install it first
# Install the old version of gcc, c++translater
sudo yum install gcc gcc-c++
# Download gcc 5.2.0 source code
wget http://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
# Source code decompression
tar xvf gcc-4.9.0.tar.bz2
cd gcc-5.2.0
# Download some necessary dependent programs
. /contrib/download_prerequisites
mkdir build && cd build
.. /configure --enable-checking=release --enable-languages=c,c++--disable-multilib
# Start to compile, single-threaded compilation takes a long time,
# Can consider using-The j parameter executes parallel compilation such as: make-j8, 8 means 8 threads in parallel,
# But if there is an error in the parallel compilation process, it is sometimes difficult to find
make
# installation,Need root privileges
sudo make install
Execute gcc --version
to verify whether the installation is successful, if the version number is displayed as 5.2.0
, the installation is successful
$ gcc –version
gcc (GCC) 5.2.0
Copyright © 2015 Free Software Foundation, Inc.
This program is free software; please refer to the copyright notice of the source code. There is no guarantee for this software;
Including no guarantees of merchantability and suitability for a specific purpose.
You can also execute gcc --v
to display more detailed version information (including compilation options)
$ gcc -v
Use built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
The configuration is: ../configure –enable-checking=release –enable-languages=c,c++ –disable-multilib
Thread model: posix
gcc version 5.2.0 (GCC)
After gcc is installed, the libstdc++ dynamic library is not updated, and it still points to version 6.0.13
$ ll /usr/lib64/libstdc++.so.6
lrwxrwxrwx. 1 root root 19 December 25 16:48 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.13
After gcc 5.2.0 is compiled, the dynamic library defaults to the following location:
/usr/local/lib64/libstdc++.so.6.0.21
Manually modify the libstdc++.so.6
soft link to complete the libstdc++ dynamic library update
sudo rm -rf /usr/lib64/libstdc++.so.6
sudo ln -s /usr/local/lib64/libstdc++.so.6.0.21/usr/lib64/libstdc++.so.6
configure: error: error verifying int64_t uses long long
The error is caused by not installing g++, it can be solved by installing g++
sudo yum install gcc-c++
"CentOS6.5 gcc upgrade method" https://www.ctguqmx.com/article/233#modile.qq.com
"Gcc 5.2.0 compilation error" http://blog.csdn.net/u012509728/article/details/49923995
"Linux upgrade installation GCC G++ 6.2" http://blog.csdn.net/furzoom/article/details/53322510
Recommended Posts