当前位置: 首页 > 知识库问答 >
问题:

通过MongoDB C++初始化分解Qt

章绪
2023-03-14

我对在QT中使用MongoDB C++很新鲜。

然而,当我想在Qt上应用相同的代码时,出现了很多问题。

总体设置:

  1. Win10
  2. 带有Qt V5.10.1 MSVC2017的Qt Creator V4.6.0 64位Microsoft Visual C++编译器15.0调试器CDB x64
  3. MongoDB v3.6.3
  4. 升压1.66.0作为lib64-msvc-14.1
  5. Mongo c驱动程序v1.9.3
  6. Mongo cxx驱动程序r3.2.0

$MongoCxx::Instance inst()

当编译为使用时产生C4930警告

$MongoCxx::Instance inst()

    INCLUDEPATH += $$PWD/driver/c/include/libbson-1.0
    DEPENDPATH += $$PWD/driver/c/include/libbson-1.0
    LIBS += -L$$PWD/driver/c/lib -lbson-1.0
    LIBS += -L$$PWD/driver/c/lib -lbson-static-1.0


    INCLUDEPATH += $$PWD/driver/c/include/libmongoc-1.0
    DEPENDPATH += $$PWD/driver/c/include/libmongoc-1.0
    LIBS += -L$$PWD/driver/c/lib -lmongoc-1.0
    LIBS += -L$$PWD/driver/c/lib -lmongoc-static-1.0

    INCLUDEPATH += $$PWD/driver/c++/include/bsoncxx/v_noabi
    DEPENDPATH += $$PWD/driver/c++/include/bsoncxx/v_noabi
    LIBS += -L$$PWD/driver/c++/lib -lbsoncxx

    INCLUDEPATH += $$PWD/driver/c++/include/mongocxx/v_noabi
    DEPENDPATH += $$PWD/driver/c++/include/mongocxx/v_noabi
    LIBS += -L$$PWD/driver/c++/lib -lmongocxx        

    INCLUDEPATH += $$PWD/driver/boost_1_66_0
    DEPENDPATH += $$PWD/driver/boost_1_66_0
    LIBS += -L$$PWD/driver/boost_1_66_0/lib64-msvc-14.1 \
        -lboost_atomic-vc141-mt-gd-x64-1_66 \
        -lboost_atomic-vc141-mt-x64-1_66 \
        -lboost_bzip2-vc141-mt-gd-x64-1_66 \
        -lboost_bzip2-vc141-mt-x64-1_66 \
        -lboost_chrono-vc141-mt-gd-x64-1_66 \
        -lboost_chrono-vc141-mt-x64-1_66 \
        -lboost_container-vc141-mt-gd-x64-1_66 \
        -lboost_container-vc141-mt-x64-1_66 \
        -lboost_context-vc141-mt-gd-x64-1_66 \
        -lboost_context-vc141-mt-x64-1_66 \
        -lboost_coroutine-vc141-mt-gd-x64-1_66 \
        -lboost_coroutine-vc141-mt-x64-1_66 \
        -lboost_date_time-vc141-mt-gd-x64-1_66 \
        -lboost_date_time-vc141-mt-x64-1_66 \
        -lboost_fiber-vc141-mt-gd-x64-1_66 \
        -lboost_fiber-vc141-mt-x64-1_66 \
        -lboost_filesystem-vc141-mt-gd-x64-1_66 \
        -lboost_filesystem-vc141-mt-x64-1_66 \
        -lboost_graph-vc141-mt-gd-x64-1_66 \
        -lboost_graph-vc141-mt-x64-1_66 \
        -lboost_iostreams-vc141-mt-gd-x64-1_66 \
        -lboost_iostreams-vc141-mt-x64-1_66 \
        -lboost_locale-vc141-mt-gd-x64-1_66 \
        -lboost_locale-vc141-mt-x64-1_66 \
        -lboost_log-vc141-mt-gd-x64-1_66 \
        -lboost_log-vc141-mt-x64-1_66 \
        -lboost_log_setup-vc141-mt-gd-x64-1_66 \
        -lboost_log_setup-vc141-mt-x64-1_66 \
        -lboost_math_c99-vc141-mt-gd-x64-1_66 \
        -lboost_math_c99-vc141-mt-x64-1_66 \
        -lboost_math_c99f-vc141-mt-gd-x64-1_66 \
        -lboost_math_c99f-vc141-mt-x64-1_66 \
        -lboost_math_c99l-vc141-mt-gd-x64-1_66 \
        -lboost_math_c99l-vc141-mt-x64-1_66 \
        -lboost_math_tr1-vc141-mt-gd-x64-1_66 \
        -lboost_math_tr1-vc141-mt-x64-1_66 \
        -lboost_math_tr1f-vc141-mt-gd-x64-1_66 \
        -lboost_math_tr1f-vc141-mt-x64-1_66 \
        -lboost_math_tr1l-vc141-mt-gd-x64-1_66 \
        -lboost_math_tr1l-vc141-mt-x64-1_66 \
        -lboost_prg_exec_monitor-vc141-mt-gd-x64-1_66 \
        -lboost_prg_exec_monitor-vc141-mt-x64-1_66 \
        -lboost_program_options-vc141-mt-gd-x64-1_66 \
        -lboost_program_options-vc141-mt-x64-1_66 \
        -lboost_python-vc141-mt-gd-x64-1_66 \
        -lboost_python-vc141-mt-x64-1_66 \
        -lboost_random-vc141-mt-gd-x64-1_66 \
        -lboost_random-vc141-mt-x64-1_66 \
        -lboost_regex-vc141-mt-gd-x64-1_66 \
        -lboost_regex-vc141-mt-x64-1_66 \
        -lboost_serialization-vc141-mt-gd-x64-1_66 \
        -lboost_serialization-vc141-mt-x64-1_66 \
        -lboost_signals-vc141-mt-gd-x64-1_66 \
        -lboost_signals-vc141-mt-x64-1_66 \
        -lboost_stacktrace_noop-vc141-mt-gd-x64-1_66 \
        -lboost_stacktrace_noop-vc141-mt-x64-1_66 \
        -lboost_stacktrace_windbg-vc141-mt-gd-x64-1_66 \
        -lboost_stacktrace_windbg-vc141-mt-x64-1_66 \
        -lboost_stacktrace_windbg_cached-vc141-mt-gd-x64-1_66 \
        -lboost_stacktrace_windbg_cached-vc141-mt-x64-1_66 \
        -lboost_system-vc141-mt-gd-x64-1_66 \
        -lboost_system-vc141-mt-x64-1_66 \
        -lboost_thread-vc141-mt-gd-x64-1_66 \
        -lboost_thread-vc141-mt-x64-1_66 \
        -lboost_timer-vc141-mt-gd-x64-1_66 \
        -lboost_timer-vc141-mt-x64-1_66 \
        -lboost_type_erasure-vc141-mt-gd-x64-1_66 \
        -lboost_type_erasure-vc141-mt-x64-1_66 \
        -lboost_unit_test_framework-vc141-mt-gd-x64-1_66 \
        -lboost_unit_test_framework-vc141-mt-x64-1_66 \
        -lboost_wave-vc141-mt-gd-x64-1_66 \
        -lboost_wave-vc141-mt-x64-1_66 \
        -lboost_wserialization-vc141-mt-gd-x64-1_66 \
        -lboost_wserialization-vc141-mt-x64-1_66 \
        -lboost_zlib-vc141-mt-gd-x64-1_66 \
        -lboost_zlib-vc141-mt-x64-1_66 \
        -llibboost_atomic-vc141-mt-gd-x64-1_66 \
        -llibboost_atomic-vc141-mt-s-x64-1_66 \
        -llibboost_atomic-vc141-mt-sgd-x64-1_66 \
        -llibboost_atomic-vc141-mt-x64-1_66 \
        -llibboost_bzip2-vc141-mt-gd-x64-1_66 \
        -llibboost_bzip2-vc141-mt-s-x64-1_66 \
        -llibboost_bzip2-vc141-mt-sgd-x64-1_66 \
        -llibboost_bzip2-vc141-mt-x64-1_66 \
        -llibboost_chrono-vc141-mt-gd-x64-1_66 \
        -llibboost_chrono-vc141-mt-s-x64-1_66 \
        -llibboost_chrono-vc141-mt-sgd-x64-1_66 \
        -llibboost_chrono-vc141-mt-x64-1_66 \
        -llibboost_container-vc141-mt-gd-x64-1_66 \
        -llibboost_container-vc141-mt-s-x64-1_66 \
        -llibboost_container-vc141-mt-sgd-x64-1_66 \
        -llibboost_container-vc141-mt-x64-1_66 \
        -llibboost_context-vc141-mt-gd-x64-1_66 \
        -llibboost_context-vc141-mt-s-x64-1_66 \
        -llibboost_context-vc141-mt-sgd-x64-1_66 \
        -llibboost_context-vc141-mt-x64-1_66 \
        -llibboost_coroutine-vc141-mt-gd-x64-1_66 \
        -llibboost_coroutine-vc141-mt-s-x64-1_66 \
        -llibboost_coroutine-vc141-mt-sgd-x64-1_66 \
        -llibboost_coroutine-vc141-mt-x64-1_66 \
        -llibboost_date_time-vc141-mt-gd-x64-1_66 \
        -llibboost_date_time-vc141-mt-s-x64-1_66 \
        -llibboost_date_time-vc141-mt-sgd-x64-1_66 \
        -llibboost_date_time-vc141-mt-x64-1_66 \
        -llibboost_exception-vc141-mt-gd-x64-1_66 \
        -llibboost_exception-vc141-mt-s-x64-1_66 \
        -llibboost_exception-vc141-mt-sgd-x64-1_66 \
        -llibboost_exception-vc141-mt-x64-1_66 \
        -llibboost_fiber-vc141-mt-gd-x64-1_66 \
        -llibboost_fiber-vc141-mt-s-x64-1_66 \
        -llibboost_fiber-vc141-mt-sgd-x64-1_66 \
        -llibboost_fiber-vc141-mt-x64-1_66 \
        -llibboost_filesystem-vc141-mt-gd-x64-1_66 \
        -llibboost_filesystem-vc141-mt-s-x64-1_66 \
        -llibboost_filesystem-vc141-mt-sgd-x64-1_66 \
        -llibboost_filesystem-vc141-mt-x64-1_66 \
        -llibboost_graph-vc141-mt-gd-x64-1_66 \
        -llibboost_graph-vc141-mt-s-x64-1_66 \
        -llibboost_graph-vc141-mt-sgd-x64-1_66 \
        -llibboost_graph-vc141-mt-x64-1_66 \
        -llibboost_iostreams-vc141-mt-gd-x64-1_66 \
        -llibboost_iostreams-vc141-mt-s-x64-1_66 \
        -llibboost_iostreams-vc141-mt-sgd-x64-1_66 \
        -llibboost_iostreams-vc141-mt-x64-1_66 \
        -llibboost_locale-vc141-mt-gd-x64-1_66 \
        -llibboost_locale-vc141-mt-s-x64-1_66 \
        -llibboost_locale-vc141-mt-sgd-x64-1_66 \
        -llibboost_locale-vc141-mt-x64-1_66 \
        -llibboost_log-vc141-mt-gd-x64-1_66 \
        -llibboost_log-vc141-mt-s-x64-1_66 \
        -llibboost_log-vc141-mt-sgd-x64-1_66 \
        -llibboost_log-vc141-mt-x64-1_66 \
        -llibboost_log_setup-vc141-mt-gd-x64-1_66 \
        -llibboost_log_setup-vc141-mt-s-x64-1_66 \
        -llibboost_log_setup-vc141-mt-sgd-x64-1_66 \
        -llibboost_log_setup-vc141-mt-x64-1_66 \
        -llibboost_math_c99-vc141-mt-gd-x64-1_66 \
        -llibboost_math_c99-vc141-mt-s-x64-1_66 \
        -llibboost_math_c99-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_c99-vc141-mt-x64-1_66 \
        -llibboost_math_c99f-vc141-mt-gd-x64-1_66 \
        -llibboost_math_c99f-vc141-mt-s-x64-1_66 \
        -llibboost_math_c99f-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_c99f-vc141-mt-x64-1_66 \
        -llibboost_math_c99l-vc141-mt-gd-x64-1_66 \
        -llibboost_math_c99l-vc141-mt-s-x64-1_66 \
        -llibboost_math_c99l-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_c99l-vc141-mt-x64-1_66 \
        -llibboost_math_tr1-vc141-mt-gd-x64-1_66 \
        -llibboost_math_tr1-vc141-mt-s-x64-1_66 \
        -llibboost_math_tr1-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_tr1-vc141-mt-x64-1_66 \
        -llibboost_math_tr1f-vc141-mt-gd-x64-1_66 \
        -llibboost_math_tr1f-vc141-mt-s-x64-1_66 \
        -llibboost_math_tr1f-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_tr1f-vc141-mt-x64-1_66 \
        -llibboost_math_tr1l-vc141-mt-gd-x64-1_66 \
        -llibboost_math_tr1l-vc141-mt-s-x64-1_66 \
        -llibboost_math_tr1l-vc141-mt-sgd-x64-1_66 \
        -llibboost_math_tr1l-vc141-mt-x64-1_66 \
        -llibboost_prg_exec_monitor-vc141-mt-gd-x64-1_66 \
        -llibboost_prg_exec_monitor-vc141-mt-s-x64-1_66 \
        -llibboost_prg_exec_monitor-vc141-mt-sgd-x64-1_66 \
        -llibboost_prg_exec_monitor-vc141-mt-x64-1_66 \
        -llibboost_program_options-vc141-mt-gd-x64-1_66 \
        -llibboost_program_options-vc141-mt-s-x64-1_66 \
        -llibboost_program_options-vc141-mt-sgd-x64-1_66 \
        -llibboost_program_options-vc141-mt-x64-1_66 \
        -llibboost_python-vc141-mt-gd-x64-1_66 \
        -llibboost_python-vc141-mt-s-x64-1_66 \
        -llibboost_python-vc141-mt-sgd-x64-1_66 \
        -llibboost_python-vc141-mt-x64-1_66 \
        -llibboost_random-vc141-mt-gd-x64-1_66 \
        -llibboost_random-vc141-mt-s-x64-1_66 \
        -llibboost_random-vc141-mt-sgd-x64-1_66 \
        -llibboost_random-vc141-mt-x64-1_66 \
        -llibboost_regex-vc141-mt-gd-x64-1_66 \
        -llibboost_regex-vc141-mt-s-x64-1_66 \
        -llibboost_regex-vc141-mt-sgd-x64-1_66 \
        -llibboost_regex-vc141-mt-x64-1_66 \
        -llibboost_serialization-vc141-mt-gd-x64-1_66 \
        -llibboost_serialization-vc141-mt-s-x64-1_66 \
        -llibboost_serialization-vc141-mt-sgd-x64-1_66 \
        -llibboost_serialization-vc141-mt-x64-1_66 \
        -llibboost_signals-vc141-mt-gd-x64-1_66 \
        -llibboost_signals-vc141-mt-s-x64-1_66 \
        -llibboost_signals-vc141-mt-sgd-x64-1_66 \
        -llibboost_signals-vc141-mt-x64-1_66 \
        -llibboost_stacktrace_noop-vc141-mt-gd-x64-1_66 \
        -llibboost_stacktrace_noop-vc141-mt-s-x64-1_66 \
        -llibboost_stacktrace_noop-vc141-mt-sgd-x64-1_66 \
        -llibboost_stacktrace_noop-vc141-mt-x64-1_66 \
        -llibboost_stacktrace_windbg-vc141-mt-gd-x64-1_66 \
        -llibboost_stacktrace_windbg-vc141-mt-s-x64-1_66 \
        -llibboost_stacktrace_windbg-vc141-mt-sgd-x64-1_66 \
        -llibboost_stacktrace_windbg-vc141-mt-x64-1_66 \
        -llibboost_stacktrace_windbg_cached-vc141-mt-gd-x64-1_66 \
        -llibboost_stacktrace_windbg_cached-vc141-mt-s-x64-1_66 \
        -llibboost_stacktrace_windbg_cached-vc141-mt-sgd-x64-1_66 \
        -llibboost_stacktrace_windbg_cached-vc141-mt-x64-1_66 \
        -llibboost_system-vc141-mt-gd-x64-1_66 \
        -llibboost_system-vc141-mt-s-x64-1_66 \
        -llibboost_system-vc141-mt-sgd-x64-1_66 \
        -llibboost_system-vc141-mt-x64-1_66 \
        -llibboost_test_exec_monitor-vc141-mt-gd-x64-1_66 \
        -llibboost_test_exec_monitor-vc141-mt-s-x64-1_66 \
        -llibboost_test_exec_monitor-vc141-mt-sgd-x64-1_66 \
        -llibboost_test_exec_monitor-vc141-mt-x64-1_66 \
        -llibboost_thread-vc141-mt-gd-x64-1_66 \
        -llibboost_thread-vc141-mt-s-x64-1_66 \
        -llibboost_thread-vc141-mt-sgd-x64-1_66 \
        -llibboost_thread-vc141-mt-x64-1_66 \
        -llibboost_timer-vc141-mt-gd-x64-1_66 \
        -llibboost_timer-vc141-mt-s-x64-1_66 \
        -llibboost_timer-vc141-mt-sgd-x64-1_66 \
        -llibboost_timer-vc141-mt-x64-1_66 \
        -llibboost_type_erasure-vc141-mt-gd-x64-1_66 \
        -llibboost_type_erasure-vc141-mt-s-x64-1_66 \
        -llibboost_type_erasure-vc141-mt-sgd-x64-1_66 \
        -llibboost_type_erasure-vc141-mt-x64-1_66 \
        -llibboost_unit_test_framework-vc141-mt-gd-x64-1_66 \
        -llibboost_unit_test_framework-vc141-mt-s-x64-1_66 \
        -llibboost_unit_test_framework-vc141-mt-sgd-x64-1_66 \
        -llibboost_unit_test_framework-vc141-mt-x64-1_66 \
        -llibboost_wave-vc141-mt-gd-x64-1_66 \
        -llibboost_wave-vc141-mt-s-x64-1_66 \
        -llibboost_wave-vc141-mt-sgd-x64-1_66 \
        -llibboost_wave-vc141-mt-x64-1_66 \
        -llibboost_wserialization-vc141-mt-gd-x64-1_66 \
        -llibboost_wserialization-vc141-mt-s-x64-1_66 \
        -llibboost_wserialization-vc141-mt-sgd-x64-1_66 \
        -llibboost_wserialization-vc141-mt-x64-1_66 \
        -llibboost_zlib-vc141-mt-gd-x64-1_66 \
        -llibboost_zlib-vc141-mt-s-x64-1_66 \
        -llibboost_zlib-vc141-mt-sgd-x64-1_66 \
        -llibboost_zlib-vc141-mt-x64-1_66

共有1个答案

闻人鸿飞
2023-03-14

我在mongodb邮件列表上回复了你,但是你在这里做的很多事情都是不正确的。您不应该同时链接库的静态版本和动态版本。您不应该同时链接boost库的零售版本和调试版本等。您应该确保链接的是boost库、QT库和MongoCxx/bsonCxx/libMongoC/libbson库W.R.T的一致版本。调试/释放、静态/动态等。

我建议从最初的原则开始,根据需要逐步建立。以mongocxx项目中的一个例子为例,建立一个项目,该项目根据您构建的驱动程序成功地构建它。然后添加QT支持。

 类似资料:
  • 本文向大家介绍Java初始化块及执行过程解析,包括了Java初始化块及执行过程解析的使用技巧和注意事项,需要的朋友参考一下 问题:Java对象初始化方式主要有哪几种?分别是什么? 针对上面的问题,想必大家脑海中首先浮现出的答案是构造器,没错,构造器是Java中常用的对象初始化方式。 还有一种与构造器作用非常相似的是初始化块,它可以对Java对象进行初始化操作。下面主要阐述Java的初始化块及执行过

  • Initialization 初始化 Although it doesn’t look superficially very different from initialization in C or C++, initialization in Go is more powerful. Complex structures can be built during initialization a

  • 初始化是为类、结构体或者枚举准备实例的过程。这个过需要给实例里的每一个存储属性设置一个初始值并且在新实例可以使用之前执行任何其他所必须的配置或初始化。 你通过定义初始化器来实现这个初始化过程,它更像是一个用来创建特定类型新实例的特殊的方法。不同于 Objective-C 的初始化器,Swift 初始化器不返回值。这些初始化器主要的角色就是确保在第一次使用之前某类型的新实例能够正确初始化。 类类型的

  • new iSlider(DOM, DATA, OPTIONS) Name Type Description DOM dom 容器dom节点 DATA Array 数据列表 OPTIONS Object 配置项 DOM new iSlider(DOM, DATA, OPTIONS); {HTMLElement} 容器dom节点 作为第一个参数并不是必须的,会被OPTIONS.dom覆盖,但是这十分必

  • 确认初始化操作 1)初始化操作用来清空此统计ID的统计数据 2)与启用新的统计ID不同的是,初始化操作使您不需更换网站上的统计代码就可以重新开始统计 注意:初始化操作将清除此统计ID的所有统计数据,此操作不可恢复!!!

  • 创建版本库 git 基于文件夹(工作树)进行版本控制,在一个文件夹中创建 git版本库: $ cd project/ $ git init Initialized empty Git repository in .git/ 输出信息:在当前文件夹的 .git/ 目录下创建版本库 将文件提交到 git索引: git add file1 file2 file3 …… 更方便的作法是