Step 1(第一步): Compile Environment(建立编译环境)
0. Download MongoDB Src 2.4.1
Extract it.
- Install Python: http://www.python.org/download/releases/2.7.2/.
Make sure to install the 32-bit version of python and not the 64-bit as the SCons binaries below are 32-bit.
- It is recommended you install pywin32 if you want to do parallel builds (scons -j): http://sourceforge.net/projects/pywin32/
- Install SCons:
- Add the python scripts directory (e.g., C:\Python27\Scripts) to your PATH.
- Install Boost 1.4.9,compile (注:MongoDB V2暂时只支持1.4.9)
bootstrap
.\b2
You will get some libs in “**\boost\stage\lib”(库文件在stage\lib目录下)
Step 2(第二步):Build with SCons
scons --dd --32 mongoclient.lib // build C++ client driver library
// Debug, 32bit, C++ Driver
You will get mongoclient.lib in ”**\mongodb-src-r2.4.1\build\win32\32\dd\client_build”
And some .h,.cpp files will generated in “**\mongodb-src-r2.4.1\build\win32\32\dd\mongo”
hose files will be added in sample project’s path in VS 2010.
(用Scons编译Debug 32版本的mongoclient.lib,同时会生成几个头文件,这些文件在编译例子的时候需要添加到包含文件的路径中,如果编译release版本,修改–dd为–release)
Step 3(第三步):编译例程 client/examples/simple_client_demo.vcxproj
1. Open Project(打开工程)
2. Add include directoroies(添加包含文件的路径)(boost,mongodb,mongodbClinet)
3. Add lib directories(mongodbclient.lib)
4. Compile with /MT
- Include the WinSock library in your application: Linker ‣ Input ‣ Additional Dependencies - add ws2_32.lib.
5. Run it