Как скомпилировать программу на C ++ с приводом monogcxx - PullRequest
0 голосов
/ 11 февраля 2020

Я собрал драйвер mon goc для window-10 64 с компилятором MinGW, как показано ниже по ссылке http://mongoc.org/libmongoc/current/installing.html

После успешно построенного пн goc водитель. Я собрал привод monogcxx3.4, используя приведенную ниже команду

cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=C:/mongo-cxx-driver  -DBSONCXX_POLY_USE_BOOST=1 ..

. Привод monogcxx также собирает с помощью указанной выше команды и создаю файлы библиотеки ниже

C: \ mon go - cxx-драйвер \ lib

  • libmongocxx.dll.a libbsoncxx.dll.a

C: \ mon go -cxx-driver \ bin

  • libmongocxx.dll libbsoncxx.dll

После того, как все построено, я связал библиотеку mongocxx в qt, создающую файл pro с программой c ++, как описано ниже.

INCLUDEPATH += "C:/mongo-cxx-driver/include/bsoncxx/v_noabi"
INCLUDEPATH += "C:/mongo-cxx-driver/include/mongocxx/v_noabi"


INCLUDEPATH += "C:/BackUP_mongo-c-driver/include/libbson-1.0"
INCLUDEPATH += "C:/BackUP_mongo-c-driver/include/libmongoc-1.0"


INCLUDEPATH += "C:/Development/boost_1_56/include/boost-1_56/"

LIBS +=  -L "C:\mongo-cxx-driver\bin" -lbsoncxx
LIBS +=  -L "C:\mongo-cxx-driver\bin" -lmongocxx

Test. cpp file: -

#include <iostream>
#include <cstdint>
#include <QDebug>
#include <vector>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/instance.hpp>
#include <bsoncxx/builder/stream/document.hpp>

using namespace std;
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;

int main() {

    std::cout<<"LINE"<<__LINE__<<std::endl;
    mongocxx::instance instance{}; // This should be done only once.
    mongocxx::uri uri("mongodb://localhost:27017");
    mongocxx::client client(uri);
    mongocxx::database db = client["mydb"];
    mongocxx::collection coll = db["Test"];
    return 0;
}

Эта программа успешно создана и запускается, но ничего не теряется, даже журнал отладки не печатается и MongoDB не подключен во время работы сервера MongoDB.

std::cout<<"LINE"<<__LINE__<<std::endl; 

пожалуйста, дайте мне знать, что мне не хватает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...