Due to the need to use cilk plus and std=c++14 , I decided to upgrade the compiler.
The basic tutorial is as follows:
1. Download the GCC source code :
wget
ftp://mirrors.kernel.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
2. Unzip:
tar -zxvf
gcc-5.4.0.tar.gz
3. Download the dependencies required for compilation:
cd
gcc-5.4.0 // Enter the unpacked gcc folder
./contrib/download_prerequisites
// download dependencies
cd ..
// return to upper directory
4. Create a compilation output directory:
mkdir
gcc-build-5.4.0
5. Enter the output directory, execute the following command, and generate the makefile :
cd
gcc-build-5.4.0
../gcc-5.4.0/configure –prefix=/usr/local --enable-checking=release --enable-languages=c,c++ --disable-multilib
-- The prefix is very important and must be filled in.
6. Compile:
make -j4
The next step is to wait, the whole process takes about 40 minutes. PS : It is best not to do anything else during the compilation process. The CPU is fully loaded during the whole process. If it is terminated inexplicably, there will be a lot of trouble later.
7. Installation:
After compiling, we can execute the installation:
make install
The above are all writing routine operations, and the following are the pits encountered,
braced spec is invalid
specific questions%:sanitize(xxx)
错误
,非法。
这个问题
google
了一下午,发现解决方法就只有一种,那就是将
specs
中的
%
:
sanitize(xxx)
统统改为
fsanitize=xxx
。
还有就是安装完成后
,我在我笔记本上输入
gcc -v
提示的是
5.4
。但是
centos7
这个奇葩,还要设置别的东西,要记得建立软连接:
sudo ln -s /usr/local/gcc-4.5.0/bin/gcc /usr/bin/gcc
sudo ln -s /usr/local/gcc-4.5.0/bin/g++ /usr/bin/g++
References:
1. http://blog.sina.com.cn/s/blog_73cb8ab50102uwq1.html gcc installation problemInstall multiple versions of gcc under Linux
2.https://gcc.gnu.org/ml/gcc-help/2014-12/msg00028.html Fatal error during GCC 4.9.2 build
3. https://blog.csdn.net/u012027907/article/details/45459025 Linux compile and install GCC-5.1.0