首页 > 解决方案 > CPP MongoDB 驱动程序

问题描述

嗨,我一直在尝试使用 MongoDB CPP 驱动程序,但由于某种原因,它会产生很多错误,并且仅在我需要它的特定项目中,例如在新项目中它以某种方式工作并且完全符合要求。

我已经使用 vcpkg 下载了 mongocxx 驱动程序:

cmd> vcpkg install mongo-cxx-driver[boost]:x64-windows
cmd> vcpkg integrate install

我得到的错误是: 使用 mongocxx 驱动程序时出现 VS 2019 错误



Severity    Code    Description Project File    Line    Suppression State
Error   C2039   'count': is not a member of 'mongocxx::mongocxx::v_noabi::options'  MongoDB-Exampels    C:\vcpkg\installed\x86-windows\include\mongocxx\collection.hpp  482 

Severity    Code    Description Project File    Line    Suppression State
Error   C2039   'bulk_write': is not a member of 'mongocxx::mongocxx::v_noabi::result'  MongoDB-Exampels    C:\vcpkg\installed\x86-windows\include\mongocxx\collection.hpp  257 


Severity    Code    Description Project File    Line    Suppression State
Error   C2433   'mongocxx::mongocxx::v_noabi::transaction': 'friend' not permitted on data declarations MongoDB-Exampels    C:\vcpkg\installed\x86-windows\include\mongocxx\read_concern.hpp    151 



Severity    Code    Description Project File    Line    Suppression State
Error   C2039   'aggregate': is not a member of 'mongocxx::mongocxx::v_noabi::options'  MongoDB-Exampels    C:\vcpkg\installed\x86-windows\include\mongocxx\collection.hpp  148 

以及很多缺失的错误;或)但是当我查找该行时,它似乎并不是真正的问题......

标签: c++mongodb

解决方案


我已经找到了问题的解决方案,我试图在 mt 服务器中实现这个 mongodb api,所以我使用了 winsock2 库作为套接字,显然错误是在加载 mongodb 库之前加载了 winsock2 引起的。


推荐阅读