MinGW error: ‘thread’ is not a member of ‘std’

后端 未结 3 839
野的像风
野的像风 2020-12-03 10:50

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

#include 

void Func(){
  return;
}

int main(){
  std::thread thr1(Func);
  thr         


        
相关标签:
3条回答
  • 2020-12-03 11:39

    On Window, you can choice to use POSIX thread lib to construct your app. You can find it via https://sourceforge.net/projects/pthreads4w/files/

    0 讨论(0)
  • 2020-12-03 11:48

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

    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/

    0 讨论(0)
  • 2020-12-03 11:51

    There is already a better option: https://github.com/meganz/mingw-std-threads This is a lightweight win32 native implementation of the most used threading and synchronization C++11 classes for MinGW. These are implemented in a header-only library that can co-exist with the system libs. It supports Windows XP as well, which does not have a direct analog of conditional variables.

    0 讨论(0)
提交回复
热议问题