VS2010编译Mongodb C++驱动
2014-10-22 16:41
501 查看
完成了VS2010编译Mongo C++ Driver,中间遇到了不少问题,记录一下。
1、安装scons
(1) 下载python2.7, 使用x86_32位,因为scons只有32位安装包可用;
(2) 下载scons-2.1.0;
(3) 安装python 和 scons, 将D:\Python27\Scripts写入PATH;
(4) 下载安装pywin32 ,It is recommended you install pywin32 if you want to do parallel builds (scons -j)
2、安装boost库(1.49版本).
解压后双击bootstrap.bat,生成bjam.exe后,cd到目录D:\boost下,(将boost_1_49更名为boost了)编译boost。
编译命令:D:\boost>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
这是使用VS2010环境编译的release版本,编译完成后,生成D:\boost\stage\lib文件夹,有5个lib库:
然后编译成debug版本,使用命令:bjam variant=debug --with-filesystem --with-thread --with-date_time --with-program_options threading=multi toolset=msvc-10.0 link=static runtime-link=static address-model=64
编译完成后,生成D:\boost\stage\lib文件夹,下面有10个lib库和dll:
此处为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=32 for 32 bit(32位的话,把64换为32)。link=static runtime-link=static,boost需要编译成静态库,因为mongodb只会去链接boost的静态库
address-model=64在win7 64环境下此项必须,不加在编译mongodb的c++ client时会出现链接错误。
3、下载mongo2.4.6源码 http://www.mongodb.org/downloads官网下载
编译Mongoclient.lib
cmd命令提示符下,cd到解压后的文件目录,例如我放在了E盘,E:\mongodb-src-r2.4.6,输入命令:
scons –-dd --64 mongoclient.lib // build C++ client driver library
Add --64 or --32 to get the 64- and 32-bit versions, respectively. Replace --release with --dd to build a debug build.
编译后在mongodb\build\win32\32\dd\client_build\生成mongoclient.lib.
4、测试程序
就用Mongodb自带的例子吧,使用VS2010打开E:\mongodb-src-r2.4.6\src\mongo\client\examples中的simple_client_demo.vcxproj,编译,会提示生成simple_client_demo.sln,保存。
使用debug模式,配置工程环境:打开工程->属性,配置Configuration Properties下的VC++ Directories,头文件路径添加C:\boost,Lib库路径添加boost的lib,以及mongodb client的lib:
C:\boost\stage\lib
E:\mongodb-src-r2.4.6\build\win32\32\dd\client_build
进入C/C++下面的Code Generation,将Runtime Library设置为Multi-threaded Debug (/MTd)
进入Linker下面的Input,设置Additional Dependencies,添加ws2_32.lib,psapi.lib,Dbghelp.lib,mongoclient.lib
将E:\mongodb-src-r2.4.6\build\win32\32\dd\mongo\base下生成的error_codes.h和error_codes.cpp文件,拷贝到E:\mongodb-src-r2.4.6\src\mongo\base目录下。
ok,编译、运行.
1、安装scons
(1) 下载python2.7, 使用x86_32位,因为scons只有32位安装包可用;
(2) 下载scons-2.1.0;
(3) 安装python 和 scons, 将D:\Python27\Scripts写入PATH;
(4) 下载安装pywin32 ,It is recommended you install pywin32 if you want to do parallel builds (scons -j)
2、安装boost库(1.49版本).
解压后双击bootstrap.bat,生成bjam.exe后,cd到目录D:\boost下,(将boost_1_49更名为boost了)编译boost。
编译命令:D:\boost>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
这是使用VS2010环境编译的release版本,编译完成后,生成D:\boost\stage\lib文件夹,有5个lib库:
然后编译成debug版本,使用命令:bjam variant=debug --with-filesystem --with-thread --with-date_time --with-program_options threading=multi toolset=msvc-10.0 link=static runtime-link=static address-model=64
编译完成后,生成D:\boost\stage\lib文件夹,下面有10个lib库和dll:
此处为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=32 for 32 bit(32位的话,把64换为32)。link=static runtime-link=static,boost需要编译成静态库,因为mongodb只会去链接boost的静态库
address-model=64在win7 64环境下此项必须,不加在编译mongodb的c++ client时会出现链接错误。
3、下载mongo2.4.6源码 http://www.mongodb.org/downloads官网下载
编译Mongoclient.lib
cmd命令提示符下,cd到解压后的文件目录,例如我放在了E盘,E:\mongodb-src-r2.4.6,输入命令:
scons –-dd --64 mongoclient.lib // build C++ client driver library
Add --64 or --32 to get the 64- and 32-bit versions, respectively. Replace --release with --dd to build a debug build.
编译后在mongodb\build\win32\32\dd\client_build\生成mongoclient.lib.
4、测试程序
就用Mongodb自带的例子吧,使用VS2010打开E:\mongodb-src-r2.4.6\src\mongo\client\examples中的simple_client_demo.vcxproj,编译,会提示生成simple_client_demo.sln,保存。
使用debug模式,配置工程环境:打开工程->属性,配置Configuration Properties下的VC++ Directories,头文件路径添加C:\boost,Lib库路径添加boost的lib,以及mongodb client的lib:
C:\boost\stage\lib
E:\mongodb-src-r2.4.6\build\win32\32\dd\client_build
进入C/C++下面的Code Generation,将Runtime Library设置为Multi-threaded Debug (/MTd)
进入Linker下面的Input,设置Additional Dependencies,添加ws2_32.lib,psapi.lib,Dbghelp.lib,mongoclient.lib
将E:\mongodb-src-r2.4.6\build\win32\32\dd\mongo\base下生成的error_codes.h和error_codes.cpp文件,拷贝到E:\mongodb-src-r2.4.6\src\mongo\base目录下。
ok,编译、运行.
相关文章推荐
- VS2010编译Mongodb C++驱动
- Linux下编译mongodb以及C++客户端驱动
- C++ vs2010 mongodb 编译
- Linux下编译mongodb以及C++客户端驱动
- VS2010 C++下编译调试MongoDB源码
- mongodb c++ 驱动库编译
- 编译mongodb C++驱动 windows
- MongoDB在MFC下使用C++驱动编译错误的解决
- 转VS2010 C++下编译调试MongoDB源码 代震军
- mongodb数据库 linux下编译mongodb的c++驱动
- mongodb C++驱动VS2012编译
- VS2010 C++下编译调试MongoDB“.NET研究”源码
- MongoDB c++驱动编译与安装
- VS2010 C++下编译调试MongoDB源码
- 运用VS2010编译MongoDB的c++ client
- VS2010驱动编译出现的问题
- visual studio vs2010 2012 C/C++ 编译找不到mspdb100.dll文件的解决方法
- MongoDB C++ 驱动部分问题解决方案(MongoDB C++ Driver)
- vs2010中c++编译运行后屏幕一闪而过解决方法(控制台)
- VS2010编译mysql-connector-c++