I‘m getting error on Windows 10 64-bits when trying to use the C++ std::mutex
. The code was basically written for Linux but I'm trying to port it to Windows. (You can see compiler line in the error message that I added below.)
This is my code:
#ifndef UNTITLED_LIBRARY_H
#define UNTITLED_LIBRARY_H
#include <sys/types.h>
#include <Winsock2.h>
#include <mutex>
#include <thread>
class TCPServer
{
static std::mutex mt;
};
#endif //UNTITLED_LIBRARY_H
Here is the error message:
g++ -Wall -std=c++14 -I./ library.h -o libSimpleNetwork.so -fPIC -shared
library.h:11:17: error: 'mutex' in namespace 'std' does not name a type
11 | static std::mutex mt;
| ^~~~~
library.h:8:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
7 | #include <thread>
+++ |+#include <mutex>
8 |