C++ compile error, mutex in std does not name a type in MinGW (GCC 6.3.0)

落爺英雄遲暮 提交于 2021-01-28 04:45:35

问题


I'm trying to compile Mongo C++11 driver with MinGW (G++ 6.3.0) on Windows 10 64bit. From GCC 6 release notes;

The default mode has been changed to -std=gnu++14.

My understanding is that C++11 is also supported by default. Why then do I get these error message about mutex and thread?

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:


mongocxx currently only supports MSVC on Windows, so building with MinGW might not be possible. That being said, if you're not already, I suggest passing -std=c++11 in your CMAKE_CXX_FLAGS to see if that works.



来源:https://stackoverflow.com/questions/44567784/c-compile-error-mutex-in-std-does-not-name-a-type-in-mingw-gcc-6-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!