CentOS6.5 upgrade to manually install gcc4.8.2, centos6.5gcc4.8.2

Source: Internet
Author: User

CentOS6.5 upgrade to manually install gcc4.8.2, centos6.5gcc4.8.2

 

I. Simple Installation

The operating environment CentOS6.5 64bit, the original version 4.4.7, cannot support C ++ 11 features ~, Upgrade to 4.8.2

Cannot be upgraded using yum. You need to manually download the installation package and compile it.

1.1 obtain and decompress the installation package
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, there are some gcc version for download in the http://ftp.gnu.org/gnu/gcc, the latest version has 4.9.2.

1.2 download dependencies for compilation

Reference [1]: this magical script file will help us download, configure, and install dependency libraries, saving us a lot of time and effort.

cd gcc-4.8.0 ./contrib/download_prerequisites 
1.3 create a directory for storing compiled files.
mkdir gcc-build-4.8.2cd gcc-build-4.8.2
1.4 generate Makefile
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
1.5 compile (Note: This step is very time-consuming)
make -j4

-The j4 option is the make Optimization for multi-core processors. If it fails, useMakeAnd the related optimization options can be moved to the references [2].

An error occurred while installing this step. Error description:

Compilation terminated. make [5]: *** [_ gcov_merge_add.o] Error 1 make [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 1 make [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 2 make [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 2 make [2]: leaving directory '/home/imdb/gcc-4.8.2/gcc-build-4.8.2' make [1]: *** [stage1-bubble] Error 2 make [1]: leaving directory '/home/imdb/gcc-4.8.2/gcc-build-4.8.2' make: *** [all] Error 2

Let's take a look. The errors are concentrated inX86_64unknown-linux-gnu/32/libgccAndX86_64-unknown-linux-gnu/libgcc

Install the following two software packages (for CentOS6.X only) based on references [3 ):

sudo yum -y install glibc-devel.i686 glibc-devel

In the process, the CPU is basically full:

1.6 Installation
sudo make install

 

Ii. Verify Installation

Restart and view the gcc version:

gcc -v

I tried to write a program segment tryCpp11.cc with the C ++ 11 feature and used shared_ptr.

 1 //tryCpp11.cc 2 #include <iostream> 3 #include <memory> 4  5 int main() 6 { 7     std::shared_ptr<int> pInt(new int(5)); 8     std::cout << *pInt << std::endl; 9     return 0;10 }

Verification file:

g++ -std=c++11 -o tryCpp11 tryCpp11.cc./tryCpp11

Iii. Other installation:

-Install on Ubuntu: References [3]

-Non-simple installation: References [4]

-Coexistence of multiple gcc versions:None

 

Iv. References

[1] reference main installation steps http://www.cnblogs.com/ytjjyy/p/4008096.html

Note: the second half of this article is very useful in solving dynamic libraries.

[2] make-j4 discussion http://stackoverflow.com/questions/15289250/make-j4-or-j8

[3] libgcc error http://argcv.com/articles/2946.c/comment-page-1

Note: This article provides the installation method of gcc4.7 on Ubuntu12.04.

[4] non-simple installation http://my.oschina.net/u/728245/blog/184550 another: graphic version

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.