How to solve the "access violation reading..."problems when use mongodb-cxx drivers?

341 Views Asked by At

When I try to run the code below :

     int main(int,char**){
     mongocxx::instance inst{};
     mongocxx::client conn{mongocxx::uri{"mongodb://localhost:27019"}};
     auto db = conn["test"];
  {
     auto cursor = db["restaurants"].find({});
     for (auto&& doc : cursor) {
        std::cout << bsoncxx::to_json(doc) << std::endl;
    }
     getchar();
     return 0;      
   }

it works well in debug build,but crashed in the release build, i have rebuild the mongo-cxx-driver several times,and it didn't worked too. i have tried the ideas as

Why is there an access violation on connecting to MongoDB from C++?
Mongodb cxx + Unreal Engine 4 - Crash while iterating over Cursor
 Mongodb Cxx Driver Test crashing in Release Build [ Works fine in Debug ]
mentioned,Unfortunately, it is still not working properly. so can someone give me some advices to slove this problems?

Esteem it a favor

0

There are 0 best solutions below