Gcc Std::Thread Not Found in Namespace Std

GCC std::thread not found in namespace std

Works fine on Linux (g++ -std=c++0x -lpthread with no additional defines).

However, this thread on Cygwin mailing list suggests that, at least as of 4.4, _GLIBCXX_HAS_GTHREADS was disabled by an autoconf test when building libstdc++ because pthread implementation of cygwin is missing pthread_mutex_timedlock. Perhaps MinGW has the same problem.

Also, this thread on comp.lang.c++.moderated says the same thing. Not supported by the library.

thread is not a member of std c++

The code you present never does #include <thread>. So how is the compiler supposed to know what a std::thread is?

Fix your problem by adding #include <thread> to the top of your file.

Also make sure you use a compiler that actually supports C++11 (or later) and std::thread.

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

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.

Error: 'thread' in namespace 'std' does not name a type

The version of GCC that CodeBlocks ships with doesn't support threads (or at least it was the case last time I checked). You'll have to install a better compiler, and configure CB to use it.

You can get a fresh version of GCC from MSYS2. Or you can install one of the numerous MinGW-w64 distributions.

Why doesn't my compiler recognize #include thread (c++)?

MinGW-w64 by default comes with native (Win32) instead of POSIX threads support, and unfortunately there is currently no Win32 gthreads implementation (the threading subsystem of libstdc++), hence no threading functionality in GCC.

You need to switch from x86_64-w64-mingw32-g++-win32 to x86_64-w64-mingw32-g++-posix package to get std::thread working in MinGW-w64.

The question mingw-w64 threads: posix vs win32 discusses this issue in more detail.

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

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/



Related Topics



Leave a reply



Submit