c++编译错误

g++ test.cpp  -o test  -lpthread

编译c++程序时报错

报错信息:

错误:#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
原因:少了链接参数

g++ test.cpp  -o test   -std=c++11

编译还是报错

报错信息:

g++: 错误: -std=c++11:没有那个文件或目录

g++  -std=c++11 test.cpp -o test -lpthread 

编译还是报错

报错信息:

g++: 错误: -o:没有那个文件或目录

最终解决办法:

g++  -std=c++11 test.cpp  -lpthread
不过生成a.out文件。

执行:

 ./a.out 
 


 

猜你喜欢

转载自blog.csdn.net/yuhan61659/article/details/81302558