How to Build a Program Using C++ Driver of Mongodb

Compiling Mongo c driver example program

Another way to fix this issue, at least in fedora 18, is to run the following commands

su -c "echo /usr/local/lib > /etc/ld.so.conf.d/mongoc.conf"
su -c "ldconfig"

which correctly link the libraries from mongo-c-driver.

Problems building mongo-c-driver-1.16.2 for Win64

The tutorial for building mongo-c-driver on Windows is missing the step which source should be downloaded (as the paragraphs for other platforms provide). So one might be tempted to download Source code (zip) from the releases page. This will only get you a copy of the repository when the tag was set. But it is essential to use the mongo-c-driver-1.16.2.tar.gz link on the releases page. Then everything should work.

How to compile C++ mongo project

You need to use -I and -L to specify where you have installed your mongo header(s) and library(ies):

g++ tutorial.cpp -I/path/to/mongo/include/ -pthread -L/path/to/libmongoclient 
-lboost_thread-mt -lboost_filesystem -lboost_program_options
-lboost_system -o tutorial


Related Topics



Leave a reply



Submit