Code blocks error: 'thread' is not a member of 'std'|

来源:互联网 发布:音频编辑软件for mac 编辑:程序博客网 时间:2024/05/20 15:13

代码:

#include<iostream>#include<thread>using namespace std;void hello(){    cout<<"hello kitty"<<endl;}int main(){    std::thread t(hello);    t.join();    return 0;}


 

 

 

错误原因:

没有c++11线程库支持

 

 

解决方法:

<1>从下面网站下载threads-posix 支持

http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-posix/sjlj/

<2>覆盖在MinGW目录下

<3>设置编译器为  x86_64-w64-mingw32-g++.exe 即可

<4>重启code blocks

 

结果:

 

 

 

 

 

0 0
原创粉丝点击