mongodb c++ driver(2.53)windows编译

时间:2022-09-16 08:16:10

编译环境:

(1) 下载python2.7, 使用x86_32位,因为scons只有32位安装包可用;

(2) 下载scons2.3.0,The current production release of SCons is 2.3.0;

(3)  安装python 和 scons, 将C:\Python27\Scripts写入PATH;

(4) 安装boost1.54版本的库,直接下载windows版本编译好的库,目录c:\boost

(5) 在c:\boost里建立一个include目录,然后将c:\boost\boost目录放到include里面,即c:\boost\include\boost\..

(6) 在c:\boost里建立一个lib目录,然后将boost的lib文件放在lib目录下

(7) 直接下载mongodb整个源码https://github.com/mongodb/mongo.git(最新版本2.5.3),c++ driver的源码也在其中,目录c:\mongo

(8) 修改scons的编译文件,这个文件在我机器上运行有点问题,怎么都不能取得boost lib的文件,于是直接修改源码c:\mongo\SConstruct

if use_system_version_of_library("boost"):
if not conf.CheckCXXHeader( "boost/filesystem/operations.hpp" ):
print( "can't find boost headers" )
Exit(1) conf.env.Append(CPPDEFINES=[("BOOST_THREAD_VERSION", "")])
for b in boostLibs:
l = "boost_" + b
conf.FindSysLibDep(l,
[ l + boostCompiler + "-mt" + boostVersion,
l + boostCompiler + boostVersion ], language='C++' )

修改后的代码:

boostCompiler和boostVersion是自己定义,比如我的c:\boost\lib下面的lib文件只这样的boost_filesystem-vc100-1_55.lib,所以我定义为

boostCompiler = "-vc100"
boostVersion = "-1_55"
这两个参数是可以在scons里定义的,但是我定义的没有效果,我也没有去深度查找为什么,只要能编译就可以了
if use_system_version_of_library("boost"):
if not conf.CheckCXXHeader( "boost/filesystem/operations.hpp" ):
print( "can't find boost headers" )
Exit(1) conf.env.Append(CPPDEFINES=[("BOOST_THREAD_VERSION", "")])
for b in boostLibs:
l = "boost_" + b
boostCompiler = "-vc100"           # 这里的值,根据boost版本自己修改
boostVersion = "-1_55"            # 这里的值,根据boost版本自己修改
conf.FindSysLibDep(l,
[ l + boostCompiler + "-mt" + boostVersion,
l + boostCompiler + boostVersion ], language='C++' )
print l                        # 这是我自己打印出来,看是否是正确的值
print l + boostCompiler + "-mt" + boostVersion # 这是我自己打印出来,看是否是正确的值
print l + boostCompiler + boostVersion      # 这是我自己打印出来,看是否是正确的值

开始编译mongodb c++ driver:

  (1) 打开vs2010的x64 promtp cmd

  (2) C:\mongo>scons --full --use-system-boost --extrapath=c:/boost install-mongoclient --64 --dbg=on  这样编译出来的就是64位的debug版本,是MTd的

  C:\mongo>scons --full --use-system-boost --extrapath=c:/boost install-mongoclient --64 这样是64位的release版本,是MT的

  具体scons的参数可以参考http://docs.mongodb.org/ecosystem/tutorial/download-and-compile-cpp-driver/

  我的编译过程提示:

  

C:\mongo>scons --full --use-system-boost --extrapath=c:/boost install-mongoclit --64 --dbg=on
scons: Reading SConscript files ...
win32
scons version: 2.3.0
python version: 2 7 0 'final' 0
Checking whether the C++ compiler works(cached) yes
Checking whether the C compiler works(cached) yes
Checking if C++ compiler "$CC" is MSVC... (cached) yes
Checking if C compiler "cl" is MSVC... (cached) yes
Checking for __declspec(thread)... (cached) yes
Checking for C++ header file boost/filesystem/operations.hpp... (cached) yes
Checking for C++ library boost_thread-vc100-mt-1_55... (cached) yes
boost_thread
boost_thread-vc100-mt-1_55
boost_thread-vc100-1_55
Checking for C++ library boost_filesystem-vc100-mt-1_55... (cached) yes
boost_filesystem
boost_filesystem-vc100-mt-1_55
boost_filesystem-vc100-1_55
Checking for C++ library boost_program_options-vc100-mt-1_55... (cached) yes
boost_program_options
boost_program_options-vc100-mt-1_55
boost_program_options-vc100-1_55
Checking for C++ library boost_system-vc100-mt-1_55... (cached) yes
boost_system
boost_system-vc100-mt-1_55
boost_system-vc100-1_55
Checking for C header file unistd.h... (cached) no
Checking whether clock_gettime is declared... (cached) no
Checking for C++ header file execinfo.h... (cached) no
Checking for C library pcap... (cached) no
Checking for C library wpcap... (cached) no

在vs2010中使用,注意添加头文件目录,mongodb默认生成目录是在c:/usr/local/include,boost在c:/boost/include

添加lib目录,c:/usr/local/lib,c:/boost/lib, 需要使用的lib文件Ws2_32.lib;libmongoclient.lib;DbgHelp.lib

然后就ok了,可以正常使用了,测试通过。

mongodb c++ driver(2.53)windows编译的更多相关文章

  1. MongoDB C Driver Building on Windows

    一.编译mongodb c driver: 需要先安装OpenSSL:(参见:http://bbs.aircheng.com/read-2222-1) 步骤:(MongoDB步) 1.下载Active ...

  2. windows平台下安装、编译、使用mongodb C++ driver

    本博客将记录在Win8.1 ,VS2013环境下编译.配置mongodb C++ driver的流程. 1.下载预备 下载Boost:http://sourceforge.net/projects/b ...

  3. 编译安装MongoDB C++ Driver (win8.1 vs2013)

    在C++中调用mongodb的库函数需要安装mongodb的c++driver,需要自己编译,(自己搞了一天半 =_=''' ) 官网Build MongoDB From Source 说To bui ...

  4. mongodb c++ driver 2.0编译使用

    安装boost1.48.0 在boost的官网下载boost1.48.0,链接例如以下: http://sourceforge.net/projects/boost/files/boost/1.48. ...

  5. MongoDB C Driver使用教程

    MongoDB C Driver使用教程 转载请注明出处http://www.cnblogs.com/oloroso/ 本指南提供简介 MongoDB C 驱动程序. 在 C API 的详细信息,请参 ...

  6. MongoDB C Driver and APIinstances linux MongoDB安装配置

    <一,linux平台MongoDB安装配置>在这我们使用的Centos6 yum部署的,你想搞编译,自个干!

  7. MongoDB C driver API continues

    开篇前 <1,mongoc_init() func> mongoc_init() Synopsis void mongoc_init (void); Description This fu ...

  8. mongodb C&plus;&plus; Driver安装

    前言 mongocxx官网地址 http://mongocxx.org/?jmp=docs 本文的安装版本是:mongocxx-r3.2.0.tar.gz . 参考文档安装过程http://mongo ...

  9. RedHat6&sol;Centos6&period;5安装mongodb php driver

    条件: 安装apache 安装php 1.下载mongodb phh driver 下载地址:pecl wget http://pecl.php.net/get/mongo-1.5.8.tgz 2.解 ...

随机推荐

  1. ios基础篇(二十七)—— Json解析

    一.什么是Json JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使 ...

  2. Hibernate中使用的集合类型

    department与employee是一对多关系. set <set name="emps" inverse="true"> <key co ...

  3. cf&lpar;&num;div1 A&period; Dreamoon and Sums&rpar;&lpar;数论&rpar;

    A. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input stand ...

  4. 动态规划之----我们可以用2&ast;1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2&ast;1的小矩形无重叠地覆盖一个2&ast;n的大矩形,总共有多少种方法?

    利用动态规划,一共有n列,若从左向右放小矩形,有两种放置方式: 第一种:横着放,即占用两列.此时第二行的前两个空格只能横着放,所有,总的放置次数变为1+num(2*(n-2)),其中2*(n-2)代表 ...

  5. mysql数据库误删除操作说明

    在日常运维工作中,对于mysql数据库的备份是至关重要的!数据库对于网站的重要性使得我们对mysql数据的管理不容有失!然后,是人总难免会犯错误,说不定哪天大脑短路了来个误操作把数据库给删除了,怎么办 ...

  6. NOI2009 二叉查找树 【区间dp】

    [NOI2009]二叉查找树 [问题描述] 已知一棵特殊的二叉查找树.根据定义,该二叉查找树中每个结点的数据值都比它左子树结点的数据值大,而比它右子树结点的数据值小.另一方面,这棵查找树中每个结点都有 ...

  7. jQuery列表选择美化插件uichoose

    项目主页:http://www.jq22.com/jquery-info12073 演示地址:http://www.jq22.com/yanshi12073

  8. 【安富莱】【RL-TCPnet网络教程】第8章 RL-TCPnet网络协议栈移植(RTX)

    第8章        RL-TCPnet网络协议栈移植(RTX) 本章教程为大家讲解RL-TCPnet网络协议栈的RTX操作系统移植方式,学习了第6章讲解的底层驱动接口函数之后,移植就比较容易了,主要 ...

  9. getsockopt和setsockopt函数

    在Unix网络编程中通常用到getsockopt和setsockopt两个函数来获取和设置套接口的选项. getsockopt()函数用于获取任意类型.任意状态套接口的选项当前值,并把结果存入optv ...

  10. 解决vmware虚拟机克隆后启动centos报错device eth0 does not seem to be present&comma; delaying initialization

    centos启动报错: device eth0 does not seem to be present, delaying initialization ifcfg-eth0的配置文件里保存了以前的M ...