mongo-cxx-driver 库构建但持续存在链接和调试问题

2024-01-10

我正在尝试构建 mongo-cxx-driver,以便在 Windows 10 上使用 Visual Studio 2015 与 Cinder 一起使用。Cinder 使用 Boost 1.58,因此我根据其包含的 Boost 版本构建了驱动程序。

我尝试完全按照 github 上的说明进行操作,但我得到的最终库和 dll 似乎有问题。我希望得到一些帮助来调试我的编译出错的地方!

这就是我所做的,反映了官方说明here https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/

Step 1

我按照说明进行操作here http://mongoc.org/libmongoc/current/installing.html用于安装 MongoDB C 驱动程序。只需复制/粘贴 Windows 构建说明下的 CMake 调用即可完美运行。

Step 2

由于我使用的是 Windows 和 Visual Studio 2015,因此我应该使用 Polyfill 的 Boost 选项。

Step 3

我解压了从github下载的mongo-cxx-driver-3.0.2;然后我进入mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2并运行 CMake:

cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver -DLIBBSON_DIR=C:\mongo-c-driver -DBoost_INCLUDE_DIR=C:\Cinder\include\ -DLIBMONGOC_DIR=C:\mongo-c-driver -DBSONCXX_POLY_USE_BOOST=1 ..

然后构建并安装项目:

msbuild.exe ./ALL_BUILD.vcxproj
msbuild.exe ./INSTALL.vcxproj

一切运行良好,我从 CMake 得到确认,没有错误。万岁!

Issues

在测试时,我尝试运行测试程序

#include <iostream>

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

int main(int, char**) {
    std::printf("Starting mongo-cxx-driver test...\n");
    mongocxx::instance inst{};
    mongocxx::client conn{mongocxx::uri{}};

    bsoncxx::builder::stream::document document{};

    auto collection = conn["testdb"]["testcollection"];
    document << "hello" << "world";

    collection.insert_one(document.view());
    auto cursor = collection.find({});

    for (auto&& doc : cursor) {
        std::cout << bsoncxx::to_json(doc) << std::endl;
    }
    std::printf("End of demo!\n");
}

如果我在调试中运行它,那么它会在打印出数据库并显示“调试断言失败”消息后崩溃:

File: minkernel/crts/ucrt/src/appcrt/heap/debug_heap.cpp
Line: 980
Expression: __acrt_first_block == header

检查断点表明它会导致文件末尾的行出现错误 - 可能是在从该行进行清理期间

std::cout << bsoncxx::to_json(doc) << std::endl

我的第一个怀疑是 .lib 文件和 .dll 可能是为发布而构建的 - 所以我在发布中构建了它。

我收到一个错误mongo_test.exe has triggered a breakpoint断点位于深处bsoncxx.dll!bsoncxx::v_noabi::string::view_or_value::terminated().

在尝试调试时,我将插入行更改为:

mongocxx::result::insert_one result = collection.insert_one(document.view());

努力收集更多的调试信息。我惊讶地发现这不会编译并出现 C2440 错误:

'initializing': cannot convert from 'boost::optional<mongocxx::v_noabi::result::insert_one>' to 'mongocxx::v_noabi::result::insert_one' mongo_test  C:\mongo_test\src\mongo_testApp.cpp 39  

我怀疑问题可能在于我如何链接 Boost / std::experimental,但我尝试了几种不同的变体(禁用使用 boost 并使用 std::experimental 作为 polyfill),但这并没有似乎创建了一个工作库。或者也许调试/发布或 x64 与 x86 不匹配?

任何人都可以找出这个构建过程中的失误吗?

thanks!

[编辑] 运行 mongo-cxx-driver 中包含的测试,包括此处用于调试目的的输出:

~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2> MSBuild.exe .\RUN_TESTS.vcxproj
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/12/2016 3:03:11 PM.
Project "~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj" on node 1 (default targets).
Project "~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj" (1) is building "~\Downloads\mongo-cxx-dr
iver-r3.0.2\mongo-cxx-driver-r3.0.2\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
  Creating "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  All outputs are up-to-date.
FinalizeBuildStatus:
  Deleting file "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
  Touching "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\ZERO_CHECK.vcxproj" (default targets).

PrepareForBuild:
  Creating directory "x64\Debug\RUN_TESTS\".
  Creating directory "x64\Debug\RUN_TESTS\RUN_TESTS.tlog\".
InitializeBuildStatus:
  Creating "x64\Debug\RUN_TESTS\RUN_TESTS.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
PostBuildEvent:
  setlocal
  "C:\Program Files\CMake\bin\ctest.exe" --force-new-ctest-process -C Debug
  if %errorlevel% neq 0 goto :cmEnd
  :cmEnd
  endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
  :cmErrorLevel
  exit /b %1
  :cmDone
  if %errorlevel% neq 0 goto :VCEnd
  :VCEnd
  Test project C:/Users/nathan lachenmyer/Downloads/mongo-cxx-driver-r3.0.2/mongo-cxx-driver-r3.0.2
      Start 1: bson
  1/3 Test #1: bson .............................***Exception: Other  0.00 sec
      Start 2: driver
  2/3 Test #2: driver ...........................***Exception: Other  0.01 sec
      Start 3: instance
  3/3 Test #3: instance .........................***Exception: Other  0.00 sec

  0% tests passed, 3 tests failed out of 3
  Errors while running CTest

  Total Test time (real) =   0.03 sec

  The following tests FAILED:
          1 - bson (OTHER_FAULT)
          2 - driver (OTHER_FAULT)
          3 - instance (OTHER_FAULT)
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "setlocal\r [~\Downloads\mongo-cxx-d
river-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: "C:\Program Files\CMake\bin\ctest.exe" --force-new-ctest-process -C Debug
\r [~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd\r [~\Downloads
\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmEnd\r [~\Downloads\mongo-cxx-driver-r3.0.2\mo
ngo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone\r [C:\Users\nat
han lachenmyer\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmErrorLevel\r [~\Downloads\mongo-cxx-driver-r3
.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: exit /b %1\r [~\Downloads\mongo-cxx-driver-r3.0.
2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmDone\r [~\Downloads\mongo-cxx-driver-r3.0.2\m
ongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd\r [~\Downloads
\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 8. [~\Downloads\mongo-c
xx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
Done Building Project "~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj" (default targets) -- FAILED.


Build FAILED.

"~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj" (default target) (1) ->
(PostBuildEvent target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "setlocal\r [~\Downloads\mongo-cxx
-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: "C:\Program Files\CMake\bin\ctest.exe" --force-new-ctest-process -C Debug
\r [~\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd\r [~\Downloads
\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmEnd\r [~\Downloads\mongo-cxx-driver-r3.0.2\mo
ngo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone\r [C:\Users\nat
han lachenmyer\Downloads\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmErrorLevel\r [~\Downloads\mongo-cxx-driver-r3
.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: exit /b %1\r [~\Downloads\mongo-cxx-driver-r3.0.
2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmDone\r [~\Downloads\mongo-cxx-driver-r3.0.2\m
ongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd\r [~\Downloads
\mongo-cxx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 8. [~\Downloads\mongo-c
xx-driver-r3.0.2\mongo-cxx-driver-r3.0.2\RUN_TESTS.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.71

我知道这是一个老问题,但我今天遇到了它,所以我将在这里将我的解决方案发布给可能感兴趣的人。它只发生在调试模式下,当我将 /MD 更改为 /MDd 时,错误停止。您可能需要重新编译 mongocxx 以匹配您的设置。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

mongo-cxx-driver 库构建但持续存在链接和调试问题 的相关文章

  • 使用 ADAL v3 使用 ClientID 对 Dynamics 365 进行身份验证

    我正在尝试对我们的在线 Dynamics CRM 进行身份验证以使用可用的 API 我能找到的唯一关于执行此操作的官方文档是 https learn microsoft com en us dynamics365 customer enga
  • 是否可以使用 http url 作为 DirectShow .Net 中源过滤器的源位置?

    我正在使用 DirectShow Net 库创建一个过滤器图 该过滤器图通过使用 http 地址和 WM Asf Writer 来流式传输视频 然后 在网页上 我可以使用对象元素在 Windows Media Player 对象中呈现视频源
  • C#.Net 邮件将进入垃圾邮件文件夹

    我正在从 ASP net Web 应用程序发送电子邮件 邮件发送成功 没有失败 但大多数都进入了垃圾邮件文件夹 请帮助我克服垃圾邮件过滤器 我的发送邮件代码 public void SendMail string FromAddress s
  • 如何使用 openSSL 函数验证 PEM 证书的密钥长度

    如何验证以这种方式生成的 PEM 证书的密钥长度 openssl genrsa des3 out server key 1024 openssl req new key server key out server csr cp server
  • EntityHydrate 任务失败

    我最近安装了 Visual Studio 11 Beta 和 Visual Studio 2010 之后 我无法在 Visual Studio 2010 中构建依赖于 PostSharp 的项目 因此我卸载了 Visual Studio 1
  • C# 中的 Stack<> 实现

    我最近一直在实现递归目录搜索实现 并且使用堆栈来跟踪路径元素 当我使用 string Join 连接路径元素时 我发现它们被颠倒了 当我调试该方法时 我查看了堆栈 发现堆栈内部数组中的元素本身是相反的 即最近 Push 的元素位于内部数组的
  • 2个对象,完全相同(除了命名空间)c#

    我正在使用第三方的一组网络服务 但遇到了一个小障碍 在我手动创建将每个属性从源复制到目标的方法之前 我想我应该在这里寻求更好的解决方案 我有 2 个对象 一个是 Customer CustomerParty 类型 另一个是 Appointm
  • OpenGL:如何检查用户是否支持glGenBuffers()?

    我检查了文档 它说 OpenGL 版本必须至少为 1 5 才能制作glGenBuffers 工作 用户使用的是1 5版本但是函数调用会导致崩溃 这是文档中的错误 还是用户的驱动程序问题 我正在用这个glGenBuffers 对于VBO 我如
  • 在 azure blob 存储中就地创建 zip 文件

    我将文件存储在 Blob 存储帐户内的一个容器中 我需要在第二个容器中创建一个 zip 文件 其中包含第一个容器中的文件 我有一个使用辅助角色和 DotNetZip 工作的解决方案 但由于 zip 文件的大小最终可能达到 1GB 我担心在进
  • 猫鼬中的数组过滤器

    将查询转换为节点 arrayfilter 在 mongoose 中工作的版本或者如何在节点应用程序中运行它们 db getCollection student update id ObjectId 5a377d62d21a3025a3c3a
  • 读取依赖步行者输出

    I am having some problems using one of the Dlls in my application and I ran dependency walker on it i am not sure how to
  • 使用 gcc 时在头文件中查找定义的好方法是什么?

    在使用 gcc 时 有人有推荐的方法在头文件中查找定义吗 使用 MSVC 时 我只需右键单击并选择 转到定义 这非常好 我使用过 netbeans gcc 它确实有代码帮助 包括到定义的超链接 所以这是一种选择 但是 我想知道是否有任何其他
  • 调用 .ToArray() 时出现 ArgumentException

    我有一个经常被清除的列表 代码完全是这样的 VisitorAgent toPersist List
  • C++ 指针引用混淆

    struct leaf int data leaf l leaf r struct leaf p void tree findparent int n int found leaf parent 这是 BST 的一段代码 我想问一下 为什么
  • 在 Meteor 应用程序中实现 MongoDB 2.4 的全文搜索

    我正在考虑向 Meteor 应用程序添加全文搜索 我知道 MongoDB 现在支持此功能 但我对实现有一些疑问 启用文本搜索功能的最佳方法是什么 textSearchEnabled true 在 Meteor 应用程序中 有没有办法添加索引
  • 任何人都可以清楚地告诉如何在不使用像 这样的预定义函数的情况下找到带有小数值或小数值的指数吗? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 例如 2 0 5 1 414 所以想要 我是 c 的新手 所以请解释简单的逻辑 如果不是复杂的逻辑也足够了 在数学中 从整数取幂到实数
  • GSON 将带有日历的对象反序列化为带有 Mongo 日期的 json 并返回

    我有一些实体 其中包含一些日历属性 我想以将它们存储为 GSON 序列化 JSON 中的日期的方式对其进行序列化 因为 Mongo 可以将 date 存储为 new ISODate 我们通常通过使用 ExclusionStrategy 忽略
  • 声明一个负长度的数组

    当创建负长度数组时 C 中会发生什么 例如 int n 35 int testArray n for int i 0 i lt 10 i testArray i i 1 这段代码将编译 并且启用 Wall 时不会出现警告 并且似乎您可以分配
  • ContentDialog Windows 10 Mobile XAML - 全屏 - 填充

    我在项目中放置了一个 ContentDialog 用于 Windows 10 上的登录弹出窗口 当我在移动设备上运行此项目时 ContentDialog 未全屏显示 并且该元素周围有最小的填充 在键盘上可见 例如在焦点元素文本框上 键盘和内
  • 嵌入式linux编写AT命令

    我在向 GSM 模块写入 AT 命令时遇到问题 当我使用 minicom b 115200 D dev ttySP0 term vt100 时它工作完美 但我不知道如何在 C 代码中做同样的事情 我没有收到任何错误 但模块对命令没有反应 有

随机推荐