Automoc error after add include c++ driver

  • I compiled the driver, after connecting the library, the following error occurs during assembly

  • AutoMoc subprocess error


  • The moc process failed to compile

  • “SRC:/controller.h”

Hi @leogoleogoleogo , can you share more details about your build environment? What OS, driver version, IDE and compiler are you using? Are you using Qt by any chance - AutoMoc sounds related to it.

Yes, I am using QT libraries, I have compiled c++ driver with visual studio 2019 and working with c++14 and boost 1.60.0

I am not sure if this is really related to the MongoDB driver. Off hand it feels like an issue with Qt where it is failing to include some of the generated files (?)
Are you able to build successfully if you don’t include the C++ driver? Are you generating your solution also via Visual Studio or are you using a build generator like Ninja or CMake?

In this case, the problem is really with CT, if I connect mongoDB in the .cpp file, the project is built. However, if I connect MongoDB in the .h file, an error appears. The question is what could be causing this problem?

I am no QT expert and it’s even more difficult to say what’s going wrong without taking a look at the code. :slight_smile:
Would you be able to share code snippets on how you are “connecting MongoDB” in .h vs .cpp?

#include <mongocxx/uri.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/collection.hpp>

if this code is in a .h file, an error occurs :slight_smile:
and if the same code is in the .cpp file, there is no error
I have no idea how it works
XD