0

Our team is stuck on a problem with connecting MongoDB CXX driver to QtCreator 5.10. We have builded and compiled mongo-c-driver and mongo-cxx-driver with CMake and msbuild (VS 2017 compiler). We created test project in Visual Studio added needed includes, libs, dependencies (also we copied dll files to debug folder) and it worked, we have connected to our MongoDB server. But as we were trying to add those libs to QtCreator project and run test project we got this kind of errors:

C:\Qt-projects\test_mongo\main.cpp:24: error: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev'

We tried every combination of adding to .pro file these commands: LIBS += , INCLUDE_PATH +=. And we also tried to copy dll's to debug/release build folder.

The question is, how properly add all the includes, libs, dll's to .pro file, so the QT project could recognize MongoCXX driver?

P.S. we used this tutorial to create test project in 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)";
acm
  • 12,183
  • 5
  • 39
  • 68
A. Ko
  • 1
  • 3
  • It has nothing to do with Qt Creator (fixed the title) and not even with Qt. It has to do with Microsoft C++ linking. Very similar issue is described here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5e126c79-77f3-4d50-a47f-a9ce35cff0a4/unresolved-external-symbol-impcrtdbgreportw?forum=vcgeneral – Alexander V Dec 25 '17 at 00:15
  • But this libraries do work in VS and I don't get any errors there. The issue on this forum states that it doesn't work in VS. Or I got something wrong? – A. Ko Dec 25 '17 at 00:36
  • No idea what else is wrong with the project. The scope of the bug id definitely not Qt Creator, though. You should provide Qt project file then. Also, make sure both Qt used and app and MongoDB have same VS runtime and type of linkage (either static or dynamic). – Alexander V Dec 25 '17 at 00:40
  • Here's the .pro file of what we have tried to do https://gist.github.com/akosoj/71b6444fdf05ebdf6d42c58ef1b03564 – A. Ko Dec 25 '17 at 00:49
  • What Qt project file was imported to VS solution? That one? What else is different between Qt project file and VS solution (modified by hand?)? Look at the difference there. – Alexander V Dec 25 '17 at 01:21
  • Yes, the one by the link is Qt project file (was written by hand). Project in VS is completely different, but it states that libs are working right (libs were connected via settings tab). I just don't know how to connect this files in QtCreator project, as easy, as I did in VS. – A. Ko Dec 25 '17 at 01:39
  • Mind exact link settings you have there in VS project and transfer them over to qt app pro file. – Alexander V Dec 25 '17 at 03:45

0 Answers0