Building and installing MongoDB C++ driver in OS X
c++, mongodb, xcode
Solution
It took me a while to get this working. Hopefully you can get yours working from the following steps:
Create a new C++ project in Xcode
I copied the code from `<mongo_driver_install>/src/mongo/client/examples/tutorial.cpp` as a test
In Build Settings/Search Paths:
Add the following to your `Header Search Paths`:
/path/to/mongo-cxx-driver-nightly/src
and your equivalent path for the boost library header files (the folder should contain a `boost` folder):
/usr/local/Cellar/boost/1.54.0/include
Add the following to your `Library Search Paths`:
/usr/local/lib (in my case holds all of the boost libraries)
/path/to/mongo-cxx-driver-nightly
Link Binaries
In the `Build Phases/Link Binary with Libraries` settings:
Add the following binaries:
/path/to/mongo-cxx-driver-nightly/libmongoclient.a
/usr/local/lib/libboost_thread-mt.dylib
/usr/local/lib/libboost_system-mt.dylib
/usr/local/lib/libboost_filesystem-mt.dylib
/usr/local/lib/libboost_program_options-mt.dylib
Problem
I have downloaded the latest version of MongoDB C++ driver for my os x from http://dl.mongodb.org/dl/cxx-driver. Then I extracted using tar xvf command in os x terminal. After that I run scons to build the driver. It build successfully by giving following messages ``` -- some messages -- ranlib build/libmongoclient.a ranlib: file: build/libmongoclient.a(backtrace.o) has no symbols ranlib: file: build/libmongoclient.a(posix_fadvise.o) has no symbols ranlib: file: build/libmongoclient.a(ssl_manager.o) has no symbols Install file: "build/libmongoclient.a" as "libmongoclient.a" scons: done building targets. ``` So, then I run the command "scons install" to install the library into my machine. ``` --some messages -- scons: done reading SConscript files. scons: Building targets ... scons: `install' is up to date. scons: done building targets. ``` But when I check into the /usr/local directory for the libmongoclient libs, It's not there. But inside my extracted mongoDB driver folder, there is a file with the name of "libmongoclient.a". But there is no file with the extension of ".dylib". Then How do I use mongoDB Xcode & gcc C++ ? Somebody help me to link with "libmongoclient" library from Xcode.