std::thread is not a member of namespace std using Eclipse Kepler MinGW

前端 未结 3 629
闹比i
闹比i 2020-11-29 11:51

I\'m trying to compile a simple c++ program that uses std::thread on eclipse kepler / mingw 4.8.1 and win32. I hope to move development to linux at some point after many ye

相关标签:
3条回答
  • 2020-11-29 12:34

    I had the same problem, though I worked with Cygwin compiler instead. What I did was to define the symbol __cplusplus with the value 201103L for the preprocessor. Also I'd used the flag -std=c++11 for the compiler. This settings have to be made for All configurations (Debug & Release).

    Another thing that you may check is that you have properly installed the compiler, verify your compiler instalation as explained by rubenvb.

    0 讨论(0)
  • 2020-11-29 12:37

    See here for a native implementation that can be added to any C++11 version of MinGW: https://github.com/meganz/mingw-std-threads It is a header-only library, so you just need to include the headers in your project and you will get C++11 threads and synchronization primitives.

    0 讨论(0)
  • 2020-11-29 12:41

    Plain MinGW cannot support std::thread. You will need to use a MinGW-w64 toolchain (such as those shipped with Qt 5) that has "posix" threading enabled, so that libstdc++ exposes the <thread>, <mutex> and <future> functionality.

    You can find an installer here, but you can also try just replacing the whole mingw toolchain root folder with one of these packages. You can choose 32- or 64-bit, remember to select threads-posix if you want to play with std::thread and friends. No special compiler options other than the ones you already have are needed. I do suggest using -std=c++11 if you don't need GCC 4.6 compatibility.

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