Remoto - VFS
|
The mongocxx driver is needed to compile and use the VFS_mongo node.
This is an optional plugin that is only needed if the XML Config File(s) reference a node that uses MongoDB. In some cases this is a difficult requirement, for instance on a Raspberry Pi.
This is also outlined as a series of steps in the dockerfiles included with this repository.
References:
Requires:
1) make a work directory
export WORKDIR=~/mongo-cxx mkdir $WORKDIR
2) install mongo-c-driver:
cd $WORKDIR #wget https://github.com/mongodb/mongo-c-driver/releases/download/1.8.0/mongo-c-driver-1.8.0.tar.gz copy $VFS_DIR/../docker/base/src/mongo-c-driver-1.8.0.tar.gz $WORK_DIR/ tar xzf mongo-c-driver-1.8.0.tar.gz cd mongo-c-driver-1.8.0 ./configure --disable-automatic-init-and-cleanup
3) make and install
make sudo make install
4) install the mongo-cxx-driver:
cd $WORKDIR #git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 copy $VFS_DIR/../docker/base/src/mongo-cxx-driver-releases-v3.1.zip $WORK_DIR/ unzip mongo-cxx-driver-releases-v3.1.zip cd mongo-cxx-driver/build
5) VERY IMPORTANT!: set the PKG_CONFIG_PATH for cmake to find the mongo-c-driver:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
6) Configure the driver:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. FOR MOJAVE, may need: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DLIBBSON_DIR=/usr/local -DLIBMONGOC_DIR=/usr/local ..
7) Build the driver:
sudo make EP_mnmlstc_core make sudo make install
8) Create a test.cpp file:
cd $WORKDIR mkdir test cd test vim test.cpp (paste): #include <iostream> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/json.hpp> #include <mongocxx/client.hpp> #include <mongocxx/instance.hpp> int main(int, char**) { mongocxx::instance inst{}; mongocxx::client conn{mongocxx::uri{}}; bsoncxx::builder::stream::document document{}; auto collection = conn["testdb"]["testcollection"]; document << "hello" << "world"; collection.insert_one(document.view()); auto cursor = collection.find({}); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } } (save and exit) FOR OSX: c++ --std=c++11 test.cpp -o test $(pkg-config --cflags --libs libmongocxx) FOR LINUX: (depending on version) c++ --std=c++11 test.cpp -o test $(pkg-config --cflags --libs libmongocxx) -Wl,-rpath,/usr/local/lib
9) Make sure mongod is running on the local machine, and run the test executable
./test should output: { "_id" : { "$oid" : "59d56103115fae05102a5782" }, "hello" : "world" }