C++ 编译错误,std 中的互斥锁未命名 MinGW 中的类型(GCC 6.3.0) [英] C++ compile error, mutex in std does not name a type in MinGW (GCC 6.3.0)

查看:115
本文介绍了C++ 编译错误,std 中的互斥锁未命名 MinGW 中的类型(GCC 6.3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

我的理解是默认也支持C++11.为什么我会收到这些关于互斥锁和线程的错误消息?

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;
                                                      ^

推荐答案

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

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.

这篇关于C++ 编译错误,std 中的互斥锁未命名 MinGW 中的类型(GCC 6.3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆