CentOS 6.4 compile and install gcc 4.8.2

Compile mod_av error   pragma GCC diagnostic


The GCC version that comes with Centos 6.x is too low



1. Download the gcc 4.8.1 source code package:



http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2 


Of course gcc4.8.2 


wget http://ftp.gnu.org /gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2



2. Unzip:


tar -jxvf gcc-4.8.1.tar.bz2


3. Download the dependency packages needed for compilation:


There are two steps in this step This can be done in one way:


a) If Linux has a network connection, just do this:


cd gcc-4.8.1


./contrib/download_prerequisites


cd ..


b) If Linux does not have a network connection (my host and virtual machine are Host-only and cannot be connected to the Internet, So think of another way), then use Windows to download these packages on the Internet:


ftp://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.bz2


http://www.mpfr.org/mpfr -2.4.2/mpfr-2.4.2.tar.bz2


http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz


Someone asked, do I have to download several versions? Can I download the latest version? I haven't tried it, and don't know, I downloaded it according to the version in the gcc-4.8.1/contrib/download_prerequisites script. Now that these versions have been mentioned, I will strictly follow its requirements.


Then unzip and move to gcc-4.8.1:


tar -xjf gmp-4.3.2.tar.bz2


tar -xjf mpfr-2.4.2.tar.bz2


tar -xzf mpc-0.8.1.tar.gz


mv gmp -4.3.2 gcc-4.8.1/gmp


mv mpfr-2.4.2 gcc-4.8.1/mpfr


mv mpc-0.8.1 gcc-4.8.1/mpc


The advantage of this approach is that there is no need to separately compile gmp, mpfr and The three packages of mpc are compiled together under the gcc source code (in fact, this is also the practice of the gcc-4.8.1/contrib/download_prerequisites script, which personally feels more concise).


4. Create a new directory to store the compilation results:


mkdir gcc-build-4.8.1


5. Enter the new directory and execute the configure command to generate a makefile:


cd gcc-build-4.8.1


../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib


There is not much explanation for the specific options, you can check it yourself, I only use c and c++, so I only compile the compilers of these two languages.


6. Compile:


make -j4


I have an i5 quad core, so I open 4 threads to compile at the same time. It takes about 20 minutes to 30 minutes.


7. Installation:


sudo make install


8. You’re done, check the version:


g++ --version


g++ (GCC) 4.8.1
Copyright (C) 2013 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 PARTICULAR PURPOSE.



 





Guess you like

Origin blog.csdn.net/gredn/article/details/77802290