C ++ Mongodb driver, not working

I'm having problems using the C ++ mongo db driver. I downloaded the "legacy" branch and dynamically built it with the / MD switch using vc12.0. I am trying to connect to my database and fetch some fields from a collection, but I get a strange exception. I am using QT 5.4, code:

auto status = mongo::client::initialize();
std::string errmsg;
if(status.isOK())
{
try
{
    mongo::HostAndPort serv("127.0.0.1:27017");

    c.connect(serv,errmsg);
}
catch( const mongo::DBException &e ) {
    QString qstr(e.what());
    qDebug() << "caught " << qstr;
  }

mongo::Query query = mongo::Query("{'name':''}");
auto test = c.findOne("database.clients",query);
}

      

On the findone line I am getting an exception: Errorshttp://rghost.ru/7PsTG9Sxc/image.png

What is the correct way to do find / findone queries in a C ++ driver? And please give me work samples for other functions of the mongo driver, how to properly run it in C ++.

UPDATE

Stack Trace Exception screenshot: enter image description here

I see this is a problem with std :: string?

UPDATE 2

Ok, I created the RELEASE compilation in the qt creator and the mongo driver works fine with my release version of the programs. It seems that my / MDd program is conflicting with / MD mongodriver. However, I wanted to compile the mongodb driver with / MDd, so I can use the debugger, but! When I build the driver with dbg = on, I only get one library: libmongoclient-gd.lib. No DLL, no debug "lubmongoclient" built, as with this driver? Is it possible to build it with / MDd

+3


source to share





All Articles