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

标签 c++ mongodb visual-c++

我关注了make_vcxproj注释以创建 Visual C++ 项目。我还执行了:

scons generated-sources

用于创建丢失的文件。在 mongo 的主分支中 source code当我构建项目时出现以下错误:

Severity Code Description Project File Line Suppression State Error C2370 'kuint16max': redefinition; different storage class (compiling source file 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 分支更改为 stable 分支时,错误仍然存​​在。所以我认为问题出在我的构建中。

最佳答案

不要使用 vcproj 从源代码构建 MongoDB。它旨在供少数 Windows 开发人员在内部尽最大努力使用。相反,请按照 building.md 中的构建说明进行操作并在命令行上使用 SCons 进行构建。主分支的良好 Windows 构建命令行可能如下所示:

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

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

关于c++ - 使用Visual C++构建mongodb源码出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44352248/

相关文章:

C++ 确定是否在不定义预处理器符号的情况下使用调试符号进行编译

C++通过多个函数返回类对象

c++ - 如何在本地重新定义 boost::shared_ptr?

java - 推荐一个NoSQL数据库来替代这个包含大对象和多属性的MySQL数据库

ruby-on-rails - 如何在 rails 4.2.4 中使用正确版本的 mongo、mongoid、bson、bson_ext?

c# - 从文档中获取子元素

C++ - 无法重载赋值运算符

windows - 应用程序无法写入 %APPDATA%(但用户可以)

c++ - 如何将数据插入 map<string, set<string>> C++?

c++ - 使用 CONFIG += staticlib 构建 Qt 应用程序会导致 "undefined reference to vtable"错误