first, easy installation
Operating environment CentOS6.5 64bit, the original version 4.4.7, cannot support c++11 features ~, want to upgrade to 4.8.2
cannot be upgraded by Yum, you need to manually download the installation package and compile it
1.1 Get the installation package and unzip
wget HTTP://FTP.GNU.ORG/GNU/GCC/GCC-4.8.2/GCC-4.8.2.TAR.BZ2TAR-JXVF gcc-4.8.2.tar.bz2
Of course, HTTP://FTP.GNU.ORG/GNU/GCC has all the GCC versions available for download, and the latest version already has 4.9.2.
1.2 Download dependencies for compilation requirements
Reference [1] says: This magical script file will help us to download, configure, install dependent libraries, can save us a lot of time and effort.
CD gcc-4.8.2./contrib/download_prerequisites
1.3 Create a directory for the compiled files to be stored
mkdir GCC-BUILD-4.8.2CD gcc-build-4.8.2
1.4 Generating Makefile Files
.. /configure-enable-checking=release-enable-languages=c,c++-disable-multilib
1.5 Compilation (note: This step is time consuming)
Make-j4
The-J4 option is the make to multi-core processor optimization, if not successful use makes, the relevant optimization options can be moved to the reference [2].
I have an error while installing this step, description:
Compilation Terminated.make[5]: * * [_GCOV_MERGE_ADD.O] Error 1make[5]: Leaving directory '/home/imdb/gcc-4.8.2/ GCC-BUILD-4.8.2/X86_64-UNKNOWN-LINUX-GNU/32/LIBGCC ' make[4]: * * [multi-do] Error 1make[4]: Leaving directory '/home/imdb /GCC-4.8.2/GCC-BUILD-4.8.2/X86_64-UNKNOWN-LINUX-GNU/LIBGCC ' make[3]: * * [All-multi] Error 2make[3]: * * * waiting for unfinished tasks .... MAKE[3]: Leaving directory '/HOME/IMDB/GCC-4.8.2/GCC-BUILD-4.8.2/X86_64-UNKNOWN-LINUX-GNU/LIBGCC ' make[2]: * * * [ ALL-STAGE1-TARGET-LIBGCC] Error 2make[2]: Leaving directory '/home/imdb/gcc-4.8.2/gcc-build-4.8.2 ' make[1]: * * * [ Stage1-bubble] Error 2make[1]: Leaving directory '/home/imdb/gcc-4.8.2/gcc-build-4.8.2 ' make: * * * [ALL] Error 2
Probably look, the mistake is concentrated in x86_64unknown-linux-gnu/32/libgcc and X86_64-UNKNOWN-LINUX-GNU/LIBGCC
According to reference [3], install the following two packages (for centos6.x only):
sudo yum-y install glibc-devel.i686 glibc-devel
The CPU is basically loaded during the process:
1.6. Installation
sudo make install
Second, verify the installation
Restart, and then view the GCC version:
Gcc-v
Try to write a c++11 feature of the program segment trycpp11.cc, using the shared_ptr
1//trycpp11.cc 2 #include <iostream> 3 #include <memory> 4 5 int main () 6 {7 std::shared_ptr<int& Gt PINT (new int (5)); 8 std::cout << *pint << Std::endl; 9 return 0;10}
Verify file:
g++-std=c++11-o tryCpp11 TRYCPP11.CC./TRYCPP11
Cannot support C++11 's features ~, upgrade to 4.8.2