使用VS2010编译MongoDB的c++ client

使用VS2010编译MongoDB的c++ client

1.编译boost

boost库下载地址 http://www.boost.org/users/history/
mongodb2.1及以上版本采用boost_1_49_0,更早的mongodb版本采用boost_1_42_0。下载需要的版本库并解压。

以下命令行操作均在 Visual Studio 命令提示(2010) 下进行

(1)生成bjam: 

cd E:\MONGODB\boost_1_49_0\tools\build\v2\engine  或者 cd E:\MONGODB\boost_1_42_0\tools\jam\src   (不同的boost版本目录有所不同)

build 

window下会自动调用cl编译 

对应生成的 bjam.exe 在 E:\MONGODB\boost_1_49_0\tools\build\v2\engine\bin.ntx86 或 E:\MONGODB\boost_1_42_0\tools\jam\src\bin.ntx86


(2)编译需要的boost库 
拷贝bjam.exe到boost文件夹根目录,执行 
E:\MONGODB\boost_1_49_0>bjam variant=release --with-filesystem --with-thread --with-date_time --with-program_options threading=multi toolset=msvc-10.0 link=static runtime-link=static address-model=64 
此处为MongoDB文档中对于编译boost库的要求原文: 
When using bjam, MongoDB expects 
variant=debug for debug builds, and variant=release for release builds 
threading=multi 
link=static runtime-link=static for release builds 
address-model=64 for 64 bit 

link=static runtime-link=static,boost需要编译成静态库,因为mongodb只会去链接boost的静态库 
address-model=64在win7 64环境下此项必须,不加在编译mongodb的c++ client时会出现链接错误。 

生成的 libboost*.lib 在 E:\MONGODB\boost_1_49_0\bin.v2\libs  或  E:\MONGODB\boost_1_42_0\bin.v2\libs ,搜索*.lib 即可。

2.编译mongoclient.lib

(1)搭建编译环境

下载安装 python-2.7.3.msi 和 scons-2.2.0-setup.exe ,先装python,再装scons。

添加 C:\Python27\Scripts 到系统路径。

(2)编译mongo

下载mongodb c++ driver 源码,下载地址 http://www.mongodb.org/downloads;(注意:要点击相应版本下的 SOURCE TGZ | ZIP 连接)

解压后执行以下命令

cd E:\MONGODB\mongodb-src-r2.5.1

scons --release --64 mongoclient.lib   (64位release版本)

scons --dd --64 mongoclient.lib   (64位debug版本)

注意:有的低版本的mongo源码不包含boost源码,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值