如何使用mongo-cxx-driver设置Visual Studio项目设置?

时间:2016-11-27 12:17:25

标签: c++ mongodb visual-studio-2015 mongo-cxx-driver

我已经使用

在Windows 10上成功构建了适用于C ++的MongoDB驱动程序3.0.3版
  

CMAKE_INSTALL_PREFIX = C:\蒙戈-CXX驱动器

但我不知道如何在Visual Studio 2015中设置可以使用此驱动程序的项目 我在这里找到this post,但我不了解确切的解决方案。我尝试了以下属性但失败了:

  • C / C ++>其他包含目录:C:\ mongo -c-driver \ include \ libbson-1.0; C:\ mongo -c-driver \ include \ libmongoc-1.0; C:\ mongo-cxx-driver \ include \ bsoncxx \ v_noabi; C :\ mongocxx驱动\包括\ mongocxx \ v_noabi;%(AdditionalIncludeDirectories)
  • 链接器>其他库目录:C:\ mongo-cxx-driver \ lib;%(AdditionalLibraryDirectories)

Visual Studio没有标记任何错误,但是当我尝试编译代码时,我收到401错误。
我希望有人可以帮助我。

编辑:存储所有401错误的完整列表here

编辑:我启动了一个新项目并使用了完全相同的设置。现在我只得到14个错误。错误列表存储在此处(编辑:已删除文件)。

编辑:我添加了以下配置:

  • 配置管理器> Active Solution Platform:x64
  • C / C ++>其他包含目录:C:\ Program Files \ boost \ boost_1_62_0;

现在我得到以下errors

3 个答案:

答案 0 :(得分:0)

我也在尝试使用VS2015(Windows7)构建驱动程序。 我对项目进行了以下更改:

# C/C++ | General | Additional Include Directories:C:\work\mongo-cxx\mongo-cxx-driver-r3.0.3\src\bsoncxx\include\libbson-1.0;C:\work\mongo-cxx\mongo-cxx-driver-r3.0.3\src\mongocxx\include\libmongoc-1.0;C:\work\mongo-cxx\mongo-cxx-driver-r3.0.3\src;C:\work\mongo-cxx\libbson-1.5.0\src\bson;C:\work\mongo-cxx\mongo-c-driver-1.5.0\src\mongoc;

# C/C++ | Preprocessor | Preprocessor Definitions:MONGOCXX_STATIC;BSONCXX_STATIC;**

# Librarian | General | Additional Dependencies:libbsoncxx.lib;mongoc-static-1.0.lib;

# Librarian | General | Additional Dependencies:C:\work\mongo-cxx\mongo-cxx-driver-r3.0.3\src\bsoncxx\$(Configuration);C:\work\mongo-cxx\mongo-c-driver-1.5.0\$(Configuration);

# Librarian | General | Link Library Dependencies: Yes

但是当我尝试将静态lib与测试示例链接时,我得到链接器错误,例如:

  

未解析的外部符号__imp_bson_append_array。

似乎在项目设置中还应该更改其他内容。

答案 1 :(得分:0)

这是一个示例.vcxproj,假设组件位于不同的目录中。您可以将它与您拥有的内容进行比较:

 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <LinkIncremental>true</LinkIncremental>
    <IncludePath>c:\local\boost_1_59_0\;C:\mongo-cxx-driver\include\mongocxx\v_noabi;C:\mongo-cxx-driver\include\bsoncxx\v_noabi;C:\mongo-c-driver\include\libmongoc-1.0;C:\mongo-c-driver\include\libbson-1.0;$(IncludePath)</IncludePath>
    <LibraryPath>c:\libbson\lib;c:\mongo-c-driver\lib\;c:\mongo-cxx-driver\lib\;c:\libbson\lib;$(LibraryPath)</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>MONGOCXX_STATIC;BSONCXX_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <SDLCheck>true</SDLCheck>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies>libmongocxx.lib;libbsoncxx.lib;mongoc-static-1.0.lib;bson-1.0.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>

答案 2 :(得分:0)

首先感谢大家的帮助! 我得到了一个workig解决方案,具有以下设置:

  • 配置管理器&gt; Active Solution Platform:x64
  • C / C ++&gt;其他包含目录:C:\ mongo -c-driver \ include \ libbson-1.0; C:\ mongo -c-driver \ include \ libmongoc-1.0; C:\ mongo-cxx-driver \ include \ bsoncxx \ v_noabi; C :\ mongo-cxx-driver \ include \ mongocxx \ _ v_noabi; C:\ Program Files \ boost \ boost_1_62_0;
  • 链接器&gt;其他库目录:C:\ mongo-cxx-driver \ lib;
  • 链接器&gt;输入&gt;其他依赖项:bsoncxx.lib; mongocxx.lib;
  • 构建活动&gt;构建后事件:COPY“C:\ mongo-cxx-driver \ bin \ bsoncxx.dll”“$(OutDir)”; COPY“C:\ mongo-cxx-driver \ bin \ mongocxx.dll”“$(OutDir )“; COPY”C:\ mongo -c-driver \ bin \ libmongoc-1.0.dll“”$(OutDir)“; COPY”C:\ mongo -c-driver \ bin \ libbson-1.0.dll“”$ (OUTDIR)“;