thread is not a member of std 解決方案

簡單來說就算gcc4.7.1的API是 Win32 thread API.

轉自stackoverflow


MinGW (which is included in TDM-GCC) comes with one of two APIs for threads: either winpthreads (based on the POSIX threads API, pthreads) or the Win32 thread API. If you have a version with the Win32 thread API, std::thread is disabled. TDM-GCC 4.7.1 uses the Win32 thread API, while TDM-GCC 4.8.1 and later come with winpthreads. That's why the compiler succeeded in one case but not the other.

This leads to 2 possible solutions for the 'thread' is not a member of 'std' problem:

  • Install a version of TDM-GCC that uses winpthreads (either standalone or with Code::Blocks). This means 4.8.1 or later.
  • Use the MinGW installer, which lets you choose which thread API to install. It also lets you choose what version of MinGW (which nowadays corresponds to the version of GCC included) to install, so you can even choose an older version such as 4.7.3, which is more stable than 4.8.1.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章