MinGW错误:'thread'不是'std'的成员 [英] MinGW error: ‘thread’ is not a member of ‘std’

查看:2105
本文介绍了MinGW错误:'thread'不是'std'的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为Windows交叉编译一个简单的应用程序:

I'm trying to cross-compile for Windows a simple application:

#include <thread>

void Func(){
  return;
}

int main(){
  std::thread thr1(Func);
  thr1.detach();
  return 0;
}

这是我得到的:

$ i686-w64-mingw32-g++ -static-libstdc++ -static-libgcc -pipe -g -std=c++0x ./threadstutor.cpp 
./threadstutor.cpp: In function ‘int main()’:
./threadstutor.cpp:8:3: error: ‘thread’ is not a member of ‘std’
./threadstutor.cpp:8:15: error: expected ‘;’ before ‘thr1’
./threadstutor.cpp:9:3: error: ‘thr1’ was not declared in this scope

实际上,这个代码没有这样的问题,如果用g ++编译Ubuntu;

Actually, this code have no such problem if compile with g++ for Ubuntu; but I need to cross-compile for Windows, and here I'm stuck.

推荐答案

这个错误意味着STL你是使用不包含C ++ 11的所有功能。

This error means that the STL you are using does not contain all the features of C++11.

要在Windows中访问C ++ 11线程,您需要使用带有posix线程的Mingw构建。在这里你可以找到Mingw-Builds v4.8.1: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-posix/sjlj/

To access C++11 threads in Windows, you will need a build of Mingw with posix-threads. Here you can find Mingw-Builds v4.8.1: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-posix/sjlj/

这篇关于MinGW错误:'thread'不是'std'的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆