我们的团队遇到了将MongoDB CXX驱动程序连接到QtCreator 5.10的问题。我们使用CMake和msbuild(VS 2017编译器)构建并编译了mongo-c-driver和mongo-cxx-driver。我们在Visual Studio中创建了测试项目,添加了所需的包含,库,依赖项(我们也将dll文件复制到 debug 文件夹)并且它工作正常,我们已经连接到我们的MongoDB服务器。但是当我们尝试将这些库添加到QtCreator项目并运行测试项目时,我们遇到了这样的错误:
C:\Qt-projects\test_mongo\main.cpp:24: error: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev'
我们尝试了将.pro文件添加到这些命令的每个组合: LIBS + = , INCLUDE_PATH + = 。我们还尝试将dll复制到调试/发布构建文件夹。
问题是,如何正确添加所有包含, libs , dll&#39> .pro文件,所以QT项目可以识别MongoCXX驱动程序吗?
P.S。我们使用本教程在VS2017中创建测试项目:
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;
Build Events > Post-Build Event: 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)";