【问题标题】:Why is there an access violation on connecting to MongoDB from C++?为什么从 C++ 连接到 MongoDB 时会出现访问冲突?
【发布时间】:2017-02-12 18:03:17
【问题描述】:

当我尝试运行这段代码时

#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

int main(int argc, char **argv)
{
    mongocxx::client client{mongocxx::uri{}};
    mongocxx::database db = client["xyz"];
    std::cout << "Connected to xyz." << std::endl;
}

我总是收到这个警告

Exception thrown at 0x00007FFF7815F1FD (libmongoc-1.0.dll) in Test.exe: 0xC0000005: Access violation writing location 0x0000000000000020.

有人可以帮忙吗?

【问题讨论】:

    标签: c++ mongodb access-violation mongo-cxx-driver


    【解决方案1】:

    我通过添加修复它

    mongocxx::instance instance{};
    

    作为主函数的第一行代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-22
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多