使用Visual C ++构建mongodb源代码出错

时间:2017-06-04 08:41:06

标签: c++ mongodb visual-c++

我按照make_vcxproj注释创建了Visual C ++项目。我也执行了:

scons generated-sources

用于创建错过的文件。在mongo source code的master分支中,当我构建项目时,我得到以下错误:

  

严重级代码描述项目文件行抑制状态   错误C2370' kuint16max':重新定义;不同的存储类   (编译源文件   src \ third_party \ s2 \ base \ strtoint.cc)mongod D:\ Open   Source \ mongo \ src \ third_party \ gperftools-2.5 \ src \ base \ basictypes.h 74

似乎kuint16max中有integral_types.h一个,basictypes.h中有另一个全球定义。这是basictypes.h文件中的主要部分(与错误相关):

const uint16 kuint16max = (   (uint16) 0xFFFF);
const uint32 kuint32max = (   (uint32) 0xFFFFFFFF);
const uint64 kuint64max = ( (((uint64) kuint32max) << 32) | kuint32max );

const  int8  kint8max   = (   (  int8) 0x7F);
const  int16 kint16max  = (   ( int16) 0x7FFF);
const  int32 kint32max  = (   ( int32) 0x7FFFFFFF);
const  int64 kint64max =  ( ((( int64) kint32max) << 32) | kuint32max );

const  int8  kint8min   = (   (  int8) 0x80);
const  int16 kint16min  = (   ( int16) 0x8000);
const  int32 kint32min  = (   ( int32) 0x80000000);
const  int64 kint64min =  ( (((uint64) kint32min) << 32) | 0 );

integral_types.h

static const uint8  kuint8max  = (( uint8) 0xFF);
static const uint16 kuint16max = ((uint16) 0xFFFF);
static const uint32 kuint32max = ((uint32) 0xFFFFFFFF);
static const uint64 kuint64max = ((uint64) GG_LONGLONG(0xFFFFFFFFFFFFFFFF));
static const  int8  kint8min   = ((  int8) 0x80);
static const  int8  kint8max   = ((  int8) 0x7F);
static const  int16 kint16min  = (( int16) 0x8000);
static const  int16 kint16max  = (( int16) 0x7FFF);
static const  int32 kint32min  = (( int32) 0x80000000);
static const  int32 kint32max  = (( int32) 0x7FFFFFFF);
static const  int64 kint64min  = (( int64) GG_LONGLONG(0x8000000000000000));
static const  int64 kint64max  = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));

当我将git branch更改为stable branch时,错误仍然存​​在。所以我认为问题在我的构建中。

1 个答案:

答案 0 :(得分:1)

不要使用vcproj的东西从源代码构建MongoDB。它适用于少数Windows开发人员的内部尽力使用。相反,请遵循building.md中的构建说明,并在命令行上使用SCons构建。主分支的良好Windows构建命令行可能如下所示:

python ./buildscripts/scons.py --release -j12 --dynamic-windows --win-version-min=ws08r2 core

但是请将-j值调整为适合您的本地系统。另请注意,building.md文件略有过时(目前正在进行代码审查中的修复),您需要VS2015 Update 3以及two hotfixes