'mutex' is not a member of 'std' in MinGW 5.3.0

Amit.Desai picture Amit.Desai · May 9, 2017 · Viewed 8.6k times · Source

I am using MinGW 5.3.0 and Crypto++ 5.6.5:

C:\MinGW>g++ -std=c++11 -s -D_WIN32_WINNT=0x0501 LOG.cpp -U__STRICT_ANSI__ Decclass.cpp \
-IC:\\MinGW\\ -IC:\\MinGW\\boost -LC:\\MinGW  -lssl -lcrypto -lcryptopp -lgdi32 -lPCRYPT \
 -lz -ltiny -lwsock32 -lws2_32 -lShlwapi

Compiling results in the error below.

c:\mingw\cryptopp565\include\cryptopp\misc.h:287:14: error: 'mutex' in namespace 'std'
does not name a typestatic std::mutex s_mutex;

c:\mingw\cryptopp565\include\cryptopp\misc.h:296:18: error: 'mutex' is not a member of
'std'std::lock_guard<std::mutex> lock(s_mutex);

enter image description here

It showing 'mutex' is not a member of 'std'

Do i need anther version of MinGW ? Or can I fix this build itself?

Answer

Amit.Desai picture Amit.Desai · May 10, 2017

I fix this issue by editing "misc.h" in the path "cryptopp565\include\cryptopp\misc.h"

On the top of misc.h I included the mutex.hpp from boost library

#include "c:\mingw\include\boost\asio\detail\mutex.hpp"

and i changed namespace also from std to boost::asio::detail

static std::mutex s_mutex; 
static boost::asio::detail::mutex s_mutex;