Step 1 : Download mongo-c-driver

Step 2 : Updated GCC and G++ compiler after version 5 .current version 7 in system

Step 3 : Mongo-c-driver Version(1.15.x) version is same version and with mongo-cxx-driver (3.5.x)

3.1 bsoncxx version: 3.5.x and libbson version 1.15.x.

3.2 mongocxx version: 3.5.x and libmongoc version 1.15.x.

Step 4 : Updated CMake 3.2 or later

Step 5 : Install Mongo-cxx-driver

Run Command in your workspace

5.1 curl -OL https://github.com/mongodb/mongo-cxx-driver/archive/r3.5.0.tar.gz    
5.2 tar -xzf r3.5.0.tar.gz
5.3 cd mongo-cxx-driver-r3.5.0/build
5.4 cmake .. \ -DBUILD_VERSION=3.5.0 \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_AND_STATIC_LIBS=ON \ -DCMAKE_PREFIX_PATH=/opt/mongo-c-driver \ -DCMAKE_INSTALL_PREFIX=/opt/mongo-cxx-driver 5.5 sudo make EP_mnmlstc_core 5.6 make && sudo make install

Step 6 : Compile your program using this command:

c++ --std=c++11 example.cpp -I/opt/mongo-cxx-driver/include/mongocxx/v_noabi \ -I/usr/local/include/libmongoc-1.0 \ -I/opt/mongo-cxx-driver/include/bsoncxx/v_noabi \ -I/usr/local/include/libbson-1.0 \ -L/opt/mongo-cxx-driver/lib64 -lmongocxx -lbsoncxx

Step 7 : Example

CRUD Operation of Mongocxx

Leave a Reply