C/C++学习笔记-eclipse不支持C++11问题

转 https://blog.csdn.net/qq_35703954/article/details/81540315

std::thread的使用,结果编译报错信息如下:

 

问题分析:查看错误提示,发现thread不是命名空间std的一个成员,那么我们知道thread很明显是std的成员,那么久只有一种可能:即没有引入相关的头文件,但是检查发现,头文件也有。又知道std::thread为c++11新特性,就有可能是编译器不支持c++11。因此,尝试解决。

解决步骤(三步):

1、打开Project -> Properties -> C/C++ General -> Path and Symbols -> Tab [Symbols]. 添加 symbol : __cplusplus 并设定它的值为:201103L(两个下划线)

2、project右键-> c/c++ build ->Settings -> GCC C++ Compiler -> Miscellaneous -> Other flags后面加上 -std=c++11

3、Window-> Preference -> Build -> Settings ->Discovery -> CDT GCC Built-in Compiler Settings MinGW(shared) ->(command to get compiler specs) ${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11

哈哈,完美解决编译问题,但是当我点击运行时,又爆了错误,怎么肥事?

 

经过长时间的摸索,总有找到原因了,需要指定thread

因为程序在运行时,还需要链接库,因此解决方案:

在上面第二步的后面继续添加 project右键-> c/c++ build ->Settings -> GCC C++ Compiler -> Miscellaneous -> Other flags后面加上 -std=c++11 -pthread

注意 别忘了在链接库中同样也要添加-pthread,所以还要执行下面一步:

 

 

bug解决

posted on 2024-04-10 22:00  西沟冯衙内  阅读(9)  评论(0编辑  收藏  举报