Creating and installing the MongoDB C ++ driver in OS X

I downloaded the latest version of the MongoDB C ++ driver for my os x from http://dl.mongodb.org/dl/cxx-driver . Then I extracted the tar xvf command in the os x terminal. After that, I run scons to build the driver. It works successfully by providing the 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, I ran the scons install command 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 the / usr / local directory for libmongoclient libs, it does not exist. But inside my extracted mongoDB driver folder there is a file called "libmongoclient.a". But there is no file with the extension .dylib. Then how to use mongoDB Xcode and gcc C ++? Someone will help me link the libmongoclient library with Xcode.

+4
source share
1 answer

It took me a while to get this done. We hope you can get your work done with 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:

screen shot of search paths

Add the following to your Header Search Paths :

 /path/to/mongo-cxx-driver-nightly/src 

and your equivalent path for formatting header files (the folder should contain the 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 Binary Files

In the Build Phases/Link Binary with Libraries settings:

Screen shot of build phases

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 
+3
source

Source: https://habr.com/ru/post/1494877/


All Articles