Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error: 'mutex' in namespace 'std' does not name a type in MinGW mysys prompt

I have downloaded MinGW from the official website and installed it on my Windows 8.1 machine.

Running g++ --version gives me g++.exe (GCC) 4.8.1.

I am trying to compile the existing codebase in MinGW compiler but it is failing with the following error:

error: 'mutex' in namespace 'std' does not
name a type
     private: std::mutex m_Mutex;
              ^
error: 'condition_variable' in namespace 's

and many more errors related to locking and threading.!

I was able to compile the same codebase in Cygwin-64 without any issues. I need to build and compile successfully in MinGW in order to create some .dll files which would be compatible on MSVS.!

I have already referred the following links , but i couldn't get through the solution.

Getting std::thread/mutex to work under Win7 with mingw and g++ 4.7.2
MinGW 4.8.1 C++11 thread support

Your help would be greatly appreciated. Thanks.

like image 335
Shivaraj Bhat Avatar asked Jan 14 '15 09:01

Shivaraj Bhat


1 Answers

The old MinGW from mingw.org does not support C++11 threading facilities.

A direct alternative would be to use MSYS2 and install MinGW-w64 compilers from there, which do support the required functionality. Follow the steps in that document, and do a:

pacman -Sy mingw-w64-i686-gcc

Which will get you a 32-bit MinGW-w64 GCC. You can call it from the "MinGW-w64 32-bit Shell", or by adding <MSYS2>\mingw32\bin to PATH.

like image 137
rubenvb Avatar answered Oct 02 '22 20:10

rubenvb