CentOS 6.6 GCC upgrade
After installing Matlab yesterday, DPM compile reports an error. The following error indicates that c ++ 11g ++ is supported. However, the default gcc version of CentOS6 is 4.4.7, and the version supporting c ++ 11 is 4.8.0 or above (not sure here )? Therefore, you need to manually update GCC here.
Building with 'g++'.Error using mexcc1plus: error: unrecognized command line option "-std=c++11"
1. Download source code
For the sake of security, select 4.8.5. If you need another version, just change the version number. You can go to the GCC official website to view it.
$ wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
2. Download dependency package & Pre-install
Compiling and installing GCC requires dependencympc,mpfr,gmp
Package. Fortunately, the built-in scripts in the GCC source code can easily download dependency packages.
$ tar zxf gcc-4.8.5.tar.gz$ cd gcc-4.8.5$ ./contrib/download_prerequisites
In this script, we can see that the version number of the dependent package ismpc-0.8.1,mpfr-2.4.2,gmp-4.3.2
.
3. Compile and install
$ Cd .. // the main reason for doing so is to build the build folder $ mkdir gcc-build-4.8.5 $ mkdir/usr/local/gcc-4.8.5/out of the source code to place the include file. $ Mkdir/usr/local/gcc // place the bin + lib File $ cd gcc-build-4.8.5 $ .. /gcc-4.8.5/configure -- prefix =/usr/local/gcc-4.8.5 -- exec-prefix =/usr/local/gcc -- enable-languages ages = c, c ++ // to save time, only $ make & make install of c and c ++ are compiled here.
To avoid multiple GCC versions in the system after installation, the directory for compilation and installation is specified/usr/local/gcc-4.8.5
And/usr/local/gcc
If you do not specify–prefix
Will be installed/usr/local
.
Wait
After make, it will take a long time to get it done.
4. Environment Variable Configuration
Change the name of gcc/g ++ to the old version.
$ mv /usr/bin/gcc /usr/bin/gcc-4.4.7$ mv /usr/bin/g++ /usr/bin/g++-4.4.7
$ Export PATH =/usr/local/gcc/bin: $ PATH # use the latest gcc/g ++;
Confirm version number
$ g++ --version$ gcc --version$ which g++$ which gcc
Error 1, Build the folder to the wrong locationStubs-32.h cannot be found, CentOS is 64-bit
compilation terminated.make[5]: *** [_muldi3.o] Error 1make[5]: Leaving directory `/home/wei/gcc-4.8.5/gcc-build-4.8.5/x86_64-unknown-linux-gnu/32/libgcc'…………
Solution: Install 32-bit glibc-devel. The following parameter ignores the multi-version Problem of a software.
$ yum -y install glibc-devel.i686 --setopt=protected_multilib=false
The main cause of this error is that the newly created build folder is in the source code tree and needs to be used in another independent folder. Solution: Create a folder outside the source code and update the code after the solution.
First, weHighlyrecommend that GCC be built into a separate directory from the sources whichDoes not reside within the source tree. this is how we generally build GCC; building where srcdir = objdir shocould still work, but doesn't get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.
References1. Compile and install GCC in CentOS 2. Installing GCC: Configuration
-
Top
-
0
-
Step on