我正在尝试在 Windows 10 64 位上使用 MinGW (G++ 6.3.0) 编译 Mongo C++11 驱动程序。来自 GCC 6 发行说明;
The default mode has been changed to -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;
^
最佳答案
mongocxx 当前 only supports MSVC on Windows ,因此可能无法使用 MinGW 进行构建。话虽这么说,如果您还没有这样做,我建议在您的 CMAKE_CXX_FLAGS 中传递 -std=c++11
以查看它是否有效。
关于C++ 编译错误,std 中的互斥量未命名 MinGW (GCC 6.3.0) 中的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44567784/