mongodb c++ driver(2.53)windows编译
编译环境:
(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编译的更多相关文章
- MongoDB C Driver Building on Windows
一.编译mongodb c driver: 需要先安装OpenSSL:(参见:http://bbs.aircheng.com/read-2222-1) 步骤:(MongoDB步) 1.下载Active ...
- windows平台下安装、编译、使用mongodb C++ driver
本博客将记录在Win8.1 ,VS2013环境下编译.配置mongodb C++ driver的流程. 1.下载预备 下载Boost:http://sourceforge.net/projects/b ...
- 编译安装MongoDB C++ Driver (win8.1 vs2013)
在C++中调用mongodb的库函数需要安装mongodb的c++driver,需要自己编译,(自己搞了一天半 =_=''' ) 官网Build MongoDB From Source 说To bui ...
- mongodb c++ driver 2.0编译使用
安装boost1.48.0 在boost的官网下载boost1.48.0,链接例如以下: http://sourceforge.net/projects/boost/files/boost/1.48. ...
- MongoDB C Driver使用教程
MongoDB C Driver使用教程 转载请注明出处http://www.cnblogs.com/oloroso/ 本指南提供简介 MongoDB C 驱动程序. 在 C API 的详细信息,请参 ...
- MongoDB C Driver and APIinstances linux MongoDB安装配置
<一,linux平台MongoDB安装配置>在这我们使用的Centos6 yum部署的,你想搞编译,自个干!
- MongoDB C driver API continues
开篇前 <1,mongoc_init() func> mongoc_init() Synopsis void mongoc_init (void); Description This fu ...
- mongodb C++ Driver安装
前言 mongocxx官网地址 http://mongocxx.org/?jmp=docs 本文的安装版本是:mongocxx-r3.2.0.tar.gz . 参考文档安装过程http://mongo ...
- RedHat6/Centos6.5安装mongodb php driver
条件: 安装apache 安装php 1.下载mongodb phh driver 下载地址:pecl wget http://pecl.php.net/get/mongo-1.5.8.tgz 2.解 ...
随机推荐
- H5 APP开发必读,20个你不知道的Html5新特征和窍门
Jeffrey Way曾发表过一篇博文<28 HTML5 Features, Tips, and Techniques you Must Know >讲述了28个HTML5特征.窍门和技术 ...
- 2、分布式文件系统---HDFS
1.HDFS设计前提与目标 (1)硬件错误是常态而不是异常. 错误检测并快速自动恢复是HDFS最核心设计目标 (2)流式数据访问.运行在HDFS上的应用主要是以流式数据读取为主,做批量处理而不是用户 ...
- uCGUI窗口重绘代码分析
一.概述 µC/GUI的窗口重绘是学习者理解窗口工作原理和应用窗口操作的重点.µC/GUI的窗口重绘引入了回调机制,回调机制可以实现图形系统调用用户的代码,由于图形系统使用了剪切算法,使得屏幕重绘的效 ...
- C# foreach 原理以及模拟的实现
public class Person:IEnumerable //定义一个person类 并且 实现IEnumerable 接口 (或者不用实现此接口 直接在类 //里面写个GetEnu ...
- java Arrays.asList()和Collections.addAll()
java中的方法Arrays.asList(arg1,arg2,arg3...),经常用在将多个元素或数组转化为List中的元素,但是在使用的时候,应该注意: arg1决定返回list的元素类型(即第 ...
- Ext.QuickTips.init();
在Extjs的组件需要提示框时往往需要此语句. 首先,Ext.QuickTips是什么? 在Ext JS 4.2.0 的API中可以查到,注意在其他的Extjs版本以下查不到,这是因为在其他版本Ext ...
- SQL中Case的使用方法(下篇)(转)
接上篇 四,根据条件有选择的UPDATE. 例,有如下更新条件 工资5000以上的职员,工资减少10% 工资在2000到4600之间的职员,工资增加15% 很容易考虑的是选择执行两次UPDATE语句, ...
- 调试Android USB遇到的令人费解的问题
上周参照网上代码,做了USB的初步探测程序,工作正常 .今天从硬件部拿到了一段例程,原本打算参考它来完善自己的程序.但运行之后总是报错,逐步跟进错误,进而发现了一个匪疑所思的问题.调试一天也未发现原因 ...
- 公司的SVN服务器改变了IP地址,请问以前下载的代码如何同步,
工作根目录上 右键->TortoiseSVN->Relocate,修改URL 更新前先备份!
- xcode5编译过的xib 如何在xcode4.6下打开
IOS7一出来,对应的xcode版本变成了5了,这次xcode升级比较大,特别是在源代码编译方面,苹果下足了功夫,编译时间不到原来的一半,忽然强烈觉得android在这方面需要加强啊: 其他不多说,X ...