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
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.
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.
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.