cc1: error: unrecognized command line option "-std=gnu++11"

编译报错:cc1: error: unrecognized command line option “-std=gnu++11”

1.什么是cc1:

http://www.kbase101.com/question/22976.html
https://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Architecture
For a C source file they are the preprocessor and compiler cc1, the assembler as, and the linker collect2.
cc1是c程序编译成可执行文件的一个过程中用的工具。

2.gnu++11和c++11的区别

c++11:支持c++11特性
gnu++11:支持c++11特性,且支持gnu extension,具体扩展特性有:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html

3.支持c++11,需要gcc高版本,之前有安装gcc4.8.2

cc -v:提示gcc version 4.4.7
/usr/local/bin/gcc -v:gcc version 4.8.2 (GCC)
/usr/bin/gcc -v:gcc version 4.4.7
存在两个版本的gcc编译器,之前没有出现过问题,最近才暴露出来。

解决方法:
有两个:
解决方法1:
ln -s /usr/local/bin/gcc /usr/bin/gcc
解决方法2:卸载掉旧版
yum erase gcc gcc-c++


版权声明:本文为zxc995293774原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。