Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting std::thread/mutex to work under Win7 with mingw and g++ 4.7.2

Tags:


Greetings,

I've recently moved out of my unix shelter to test a supposedly cross-platform networking library only to discover that mingw doesn't like to be fed c++11 stuff.

I presume that I'm missing the required headers since Win7 doesn't come packed with c++11 support.

It compiles just fine with VS2012
but g++ refuses to.

error: 'thread' in namespace 'std' does not name a type error: 'mutex' in namespace 'std' does not name a type 

The question is:

How do I get a copy of c++11 headers/libs i.e. < thread > without using the ones provided by VS2012 installation.

P.S. #1 I tried mingw-get update but it still wont find < thread >
P.S. #2 I am also using -std=c++11


Sincerely,
Chris.

like image 228
gifnoc-gkp Avatar asked Jul 09 '13 15:07

gifnoc-gkp


2 Answers

These MinGW-w64 builds support C++11 threads,atomic operations etc.

  1. MinGW-builds are now integrated into the MinGW-w64 project
  2. MinGW-builds (project is old and will not be updated, see point above)
  3. MinGW-w64 rubenvb 64-bit and 32-bit builds

Note that MinGW-w64 is not 64-bit only, but does support it, unlike the old MinGW(.org) which is missing quite a lot of the new Vista+ APIs, and of course 64-bit support.

like image 61
gifnoc-gkp Avatar answered Sep 20 '22 04:09

gifnoc-gkp


Look also here: https://github.com/meganz/mingw-std-threads This is a lighter, native implementation of std::thread and others, without using the win32 port of pthreads.

like image 34
Alexander Vassilev Avatar answered Sep 22 '22 04:09

Alexander Vassilev