To get Mangrove up and running in your project, simply follow these instructions to install Mangrove on your system.
As of this writing, the MongoDB C++ driver version 3.0.2 has not been released. When installing the C++ driver, simply git checkout master
if git checkout r3.0.2
does not work.
Mangrove uses libbson and libmongoc internally. If you don’t already have a new enough version of libmongoc and libbson installed, then you need to build them.
Build and install libmongoc according to the section Building From a Release Tarball in the install instructions. libmongoc installs libbson if necessary.
Mangrove also uses the MongoDB C++11 Driver internally.
Build and install the C++ driver according to its quickstart guide .
Clone the repository, and check out the latest stable release.
git clone -b master https://github.com/mongodb-labs/mangrove
Build Mangrove with the following commands:
cd mangrove/build
[PKG_CONFIG_PATH=CXXDRIVER_INSTALL_PATH/lib/pkgconfig] cmake -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=DESIRED_INSTALL_PATH] ..
make && sudo make install
Note that if you installed the C driver and C++ driver to a path that is automatically searched by pkg-config
, you can omit the PKG_CONFIG_PATH
environment variable. If you don’t have pkg-config
, you can explicitly set the path to the libbson, libmongoc, libbsoncxx, and libmongocxx install prefixes with the -DLIBBSON_DIR
, -DLIBMONGOC_DIR
, -Dlibbsoncxx_DIR
, and -Dlibmongocxx_DIR
CMake arguments.
Once you’ve installed Mangrove, you can start using it by including and linking libmangrove
, libboson
, and libmongocxx
in your project. libmangrove
is the library that contains the actual ODM, libboson
is the BSON serialization library that powers libmangrove
, and libmongocxx
is the MongoDB C++ Driver.
If you’re using pkg-config
, using Mangrove is incredibly simple. Simply add the following two flags to your compiler invocation:
--std=c++14
$(pkg-config --libs --cflags libmangrove libboson libmongocxx)
PKG_CONFIG_PATH=MANGROVE_INSTALL_PATH/lib/pkgconfig
if you installed Mangrove in a directory not automatically searched for by pkg-config.If you’re not using pkg-config
, you’ll need to add the following flags to your compiler invocation:
--std=c++14
-IMANGROVE_INSTALL_PATH/include/mangrove/v_noabi
-IMANGROVE_INSTALL_PATH/include/boson/v_noabi
-IMANGROVE_INSTALL_PATH/include/boson/v_noabi/boson/third_party
-ICXXDRIVER_INSTALL_PATH/include/mongocxx/v_noabi
-ICDRIVER_INSTALL_PATH/include/libmongoc-1.0
-ICXXDRIVER_INSTALL_PATH/include/bsoncxx/v_noabi
-ICDRIVER_INSTALL_PATH/include/libbson-1.0
-LMANGROVE_INSTALL_PATH/lib
-LCDRIVER_INSTALL_PATH/lib
and -LCXX_DRIVER_INSTALL_PATH/lib
-lmangrove
-lboson
-lmongocxx
-lbsoncxx