C ++编译错误,std中的互斥锁没有在MinGW中命名一个类型(GCC 6.3.0)

时间:2017-06-15 12:40:13

标签: c++ mongodb c++11 gcc mingw

我正在尝试在Windows 10 64bit上使用MinGW(G ++ 6.3.0)编译Mongo C ++ 11驱动程序。从GCC 6发行说明;

  

默认模式已更改为-std = gnu ++ 14。

我的理解是默认情况下也支持C ++ 11。 为什么我会收到有关互斥和线程的错误消息?

from F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/exception/private/mongoc_error.hh:19,
from F:\Projects\Mongo\attempt_4_mingw64\mongo-cxx-driver-r3.1.1\src\mongocxx\bulk_write.cpp:20:
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:183:10: error: 'mutex' in namespace 'std' does not name a type
         std::mutex _active_instances_lock;
              ^~~~~
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:24: error: 'thread' is not a member of 'std'
         std::unordered_map<std::thread::id, instance*> _active_instances;
                            ^~~
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:24: error: 'thread' is not a member of 'std'
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:50: error: wrong number of template arguments (1, should be at least 2) 
         std::unordered_map<std::thread::id, instance*> _active_instances;
                                                      ^

1 个答案:

答案 0 :(得分:1)

mongocxx目前为only supports MSVC on Windows,因此可能无法使用MinGW进行构建。话虽如此,如果您还没有,我建议您在CMAKE_CXX_FLAGS中传递-std=c++11以查看是否有效。