在OS X中构建和安装MongoDB C ++驱动程序 [英] Building and installing MongoDB C++ driver in OS X

查看:253
本文介绍了在OS X中构建和安装MongoDB C ++驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已从 http:// dl下载我的os x的最新版本的MongoDB C ++驱动程式.mongodb.org / dl / cxx-driver 。然后我提取使用tar xvf命令在OS X终端。之后,我运行scons来构建驱动程序。

   - 一些邮件 -  
ranlib build / libmongoclient.a
ranlib:file:build / libmongoclient.a(backtrace.o)没有符号
ranlib:file:build / libmongoclient.a(posix_fadvise.o)没有符号
ranlib:file:build / libmongoclient .a(ssl_manager.o)没有符号
安装文件:build / libmongoclient.aaslibmongoclient.a
scons:done建立目标。

那么,我运行命令scons install将库安装到我的机器。

   - 一些消息 -  
scons:读取SConscript文件。
scons:构建目标...
scons:`install'是最新的。
scons:done建立目标。

但是当我检入libmongoclient libs的/ usr / local目录时,它不存在。
但是在我提取的mongoDB驱动程序文件夹中,有一个文件名为libmongoclient.a。但没有具有.dylib扩展名的文件。那么如何使用mongoDB Xcode& gcc C ++?
有人帮助我链接到libmongoclient库从Xcode。

解决方案

这需要我一段时间才能得到这个工作。希望您可以通过以下步骤获得您的工作:



在Xcode中创建一个新的C ++项目



我将< mongo_driver_install> /src/mongo/client/examples/tutorial.cpp 的代码复制为测试



在构建设置/搜索路径中:





将以下内容添加到您的标题搜索路径

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



和boost库头文件的等效路径(该文件夹应包含 boost 文件夹):

  /usr/local/Cellar/boost/1.54.0/include 

将以下内容添加到您的库搜索路径

  / usr / local / lib(在我的例子中包含所有的boost库)
/ path / to / mongo-cxx -driver-nightly

链接二进制文件



Build Phases / Link Binary with Libraries 设置中:





添加以下二进制文件:

  /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


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.

解决方案

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

这篇关于在OS X中构建和安装MongoDB C ++驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆