Search code examples
c++mongodbbsonmongo-cxx-driver

Mongodb c++ driver issue


I am getting an error saying namespace "bsoncxx::v_noabi::builder::basic" has no member "make_document", I have already added required included as per mentioned in the tutorial.

I am using mongo-cxx-driver-r3.1.1 version. i have followed example from here

here is what I have tried

       #include "maxi.h"
       #include <cstdlib>
       #include <iostream>
       #include <bsoncxx/builder/basic/array.hpp>
       #include <bsoncxx/builder/basic/document.hpp>
       #include <bsoncxx/builder/basic/kvp.hpp>
       #include <mongocxx/client.hpp>
       #include <mongocxx/instance.hpp>

    using bsoncxx::builder::basic::kvp;
    using bsoncxx::builder::basic::make_document;// here is error 
    using bsoncxx::type;

    mongocxx::instance inst{};
    mongocxx::client conn{ mongocxx::uri{ "mongodb://localhost:27017" } };

see image here

I have already tested MongoDB driver after compiling and its working perfectly. I need to use make_document option for some reason in order to achieve my goal. Not sure possible bsoncxx::builder::basic::make_document; option may have been removed or replaced with something else which I don't know.


Solution

  • In the current master branch, document.hpp file contains make_document method. if I'm not mistaken you are using stable release version.

    Take a look here. Using declaration “not found” in MongoDB c++ driver