安装mongo cpp driver
WIN32 准备好boost, python2, scons
boost库最好是从官网下预编译的,自己编的,在编mongoclient的时候可能会出现种问题
mongo-client-install\include\mongo\client\autolib.h 查看要哪个库文件
打开 Visual Studio 2012 工具命令提示终端,这样VS环境就设置好了,否则在多版本VS下会出很多问题1
2>scons --prefix=E:\work\xbdg\program\dep\mongo-client-install --sharedclient --dynamic-windows --cpppath=E:\work\xbdg\program\dep\boost_1_57_0 --libpath=E:\work\xbdg\program\dep\boost_1_57_0\lib32-msvc-11.0 --disable-warnings-as-errors --32 --dbg=off --msvc-version
=11.0 install
mongo-client-install\include\mongo\client\autolib.h 查看要哪个库文件
Linux
编译boost
–layout=tagged 生成带-mt的库名,mongo-cxx-driver-legacy-1.0.0需要这种名字的库
-j4 并行编译1
./b2 --with-chrono --with-date_time --with-regex --with-system --with-thread --build-type=complete --layout=tagged -j4 --prefix=/usr/local threading=multi install
编译mongo-cxx-driver-legacy-1.0.0
只能编动态库,静态库无法使用1
scons --prefix=/usr/local --disable-warnings-as-errors --64 --dbg=off --ssl -j4 --sharedclient --cpppath=`pwd`/../boost_1_57_0 --libpath=`pwd`/../boost_1_57_0/stage/lib --runtime-library-search-path=`pwd`/../boost_1_57_0/stage/lib install
好像3.0版后认证要用SSL
对于C++11程序要特别注意:
如果程序使用了C++11编译,则该Driver也要用C++11编译,否则就都不要使用C++11编译。
关于C++111
2
3
4
5
6
7ATTENTION FOR C++11 USERS:
If you want to use this driver for a project which gets compiled with c++11 features enabled (-std=c++11), you have to add --c++11 flag to scons, otherwise intialize the driver will crash with segmentation fault (see https://jira.mongodb.org/browse/CXX-458).
I can't enable this flag by default, because your project has to compile with -std=c++11, too. I could create an other package for reflecting this issue, if someone ask for it.
Otherwise current develop-branch of this driver is for c++11 only, but will take some time until it's usable (at least for testing).