0

我已经成功地在 Windows 10 上为 C++ 构建了 MongoDB 驱动程序的 3.0.3 版本

CMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver

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

  • 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:\mongo-cxx-driver\include\mongocxx\v_noabi;%(AdditionalIncludeDirectories)
  • 链接器 > 附加库目录:C:\mongo-cxx-driver\lib;%(AdditionalLibraryDirectories)

Visual Studio doesn't mark any errors, but when I try to compile the code, I get 401 errors.
I hope someone can help me.

EDIT: The complete list of all 401 errors is stored here.

EDIT: I startet a new project and used exactly the same settings. Now I just get 14 errors. The list of errors is stored here (EDIT: removed file).

EDIT: I added the following configuration:

  • Configuration Manager > Active Solution Platform: x64
  • C/C++ > Additional Include Directories: C:\Program Files\boost\boost_1_62_0;

Now I get the following errors.

4

3 回答 3

0

I'm also trying to build driver with VS2015 (Windows7). I made following changes to project:

# 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

But when I tried to link static lib with test example I get linker error eg:

unresolved external symbol __imp_bson_append_array.

It seems there is something else which should be changed in project settings.

于 2016-12-01T13:36:18.090 回答
0

Here's a sample .vcxproj, assuming components are in separate directories. You can compare it to what you have:

 <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>
于 2016-12-02T20:21:41.283 回答
0

First thank everyone for help! I got a workig solution with the following set up:

  • Configuration Manager > Active Solution Platform: x64
  • C/C++ > Additional Include Directories: 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;
  • Linker > Additional Library Directories: C:\mongo-cxx-driver\lib;
  • Linker > Input > Additional Dependencies: bsoncxx.lib;mongocxx.lib;
  • 构建事件 > 构建后事件: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)";
于 2016-12-12T00:13:14.820 回答