scons编译mongodb(vs2008版本)遇到的问题总结

OS:win7 64

boost:1.49 

mongodb:2.4.6(推荐64位版本,当然如果你系统是32位的,只能使用32的版本了)

IDE:vs2008(2010的同学请跳过吧,因为官网提供的就是2010的版本)

因为项目的需求,要提供vc2008的版本,不得已才折腾的,╮(╯▽╰)╭

-------------------------------------------------------------------------

编译参考,虽然是vs2010的,但是vs2008同理:

http://www.cnblogs.com/geosky/archive/2013/05/05/VS2010-MongoDB-Cpp-Driver.html

遇到的问题:

1.'cl' is not recognized as an internal or external command,
operable program or batch file.

参考:https://groups.google.com/forum/#!msg/rt-thread-cnusers/kH9rP_ih8DQ/4lFj67_vlREJ

修改方法:
在  $PYTHON\scons-2.2.0\SCons\Tool\MSCommon\vc.py

# Dict to 'canonalize' the arch
_ARCH_TO_CANONICAL = {
    "amd64"     : "amd64",
    "emt64"     : "amd64",
    "i386"      : "x86",
    "i486"      : "x86",
    "i586"      : "x86",
    "i686"      : "x86",
    "ia64"      : "ia64",
    "itanium"   : "ia64",
    "x86"       : "x86",
    "x86_64"    : "x86",
    #"x86_64"    : "amd64",
}

原因可能是我安装vs2008不支持x86_64,所以不能接受“amd64”编译参数,这样修改后,只能编译32位的版本了,注意!

解决办法2:

打sp1的补丁

ISO版的SP1(即VS2008SP1CHSX1512981_20080811.iso):http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61

现在不打sp1的补丁,后面会遇到编译错误,还是要打的。

2.编译的时候找不到“cstdint.h”头文件

这个头文件本身是C11里面的东西。vc2010的sdk有这个,vs2008没有这个。观察这个头文件,只是一些数据类型的定义,故可以替换之.

 使用msinttypes里面stdint.h替换下:https://code.google.com/p/msinttypes/downloads/detail?name=msinttypes-r26.zip&can=2&q=

把stdint.h放到你的vc的sdk目录下,类似这样目录:Microsoft SDKs\Windows\v6.0A\Include

并且修改“mongodb-src-r2.4.6\src\mongo\platform”下面cstdint.h中相关代码:

1 #if defined(_MSC_VER)
2 #include <stdint.h> /* #include <cstdint.h> */
3 #define _MONGO_STDINT_NAMESPACE  /* #define _MONGO_STDINT_NAMESPACE std */

3.编译的时候找不到“EADDRINUSE”和“ECONNABORTED”的定义

打开“mongodb-src-r2.4.6\src\mongo\util\net”下的"listen.cpp",做如下修改:

 1 #include "pch.h"
 2 #include "listen.h"
 3 #include "message_port.h"
 4 #include "mongo/base/owned_pointer_vector.h"
 5 
 6 #ifdef _WIN32
 7  #define EADDRINUSE     WSAEADDRINUSE
 8  #define ECONNABORTED   WSAECONNABORTED
 9 #endif
10 
11 #ifndef _WIN32
12 
13 # ifndef __sunos__
14 #  include <ifaddrs.h>
15 # endif
16 # include <sys/resource.h>
17 # include <sys/stat.h>

 

 后面再把整个工程放上来,还有一点细节要修改。待续

posted @ 2013-10-11 18:42  汤豆豆  阅读(4489)  评论(1编辑  收藏  举报