Solved MongoDB integration with Qt
-
home/../mongo/bsoncxx/v_noabi/bsoncxx/types.hp:39: Parse error at "{" make[1]: *** [Makefile:1117: moc_server.cpp] Error 1
This is what I get in the compilation output, if it is useful
-
Well, without the code, it doesn't help much.
-
A minimal piece of code to reproduce the error is already available here https://bugreports.qt.io/browse/QTBUG-80578, but it seems to be a bug. Unfortunately, I didn't find any workaround and I'm unable to continue with the project.
-
You wrote that the compilation was successful so that part is fine, isn't it ?
As for the run time crash, what is the stack trace ?
-
-
Do you have the same issue if you write a minimal test application using only bsoncxx ?
-
In the end, it was a problem of compatibility between mongocxx and my Qt version. Installing a previous release fixed the issue.
-
@enne9 said in MongoDB integration with Qt:
n mongocxx and my Qt version. I
so, what was the compatible versions?
-
I confirm that I have the very same issue with Qt 5.15.2 and mongo-cxx-driver 3.5.0 (had to add Q_MOC_RUN defines, and then the same crash when building mongocxx::client).
If the author of the thread show up again, which combination of version did you use that worked ? Did you perhaps use the legacy mongo-cxx-driver ? Considering how different the two are, it might work... but the new generation of mongo-cxx-driver is already pretty damn mature, and the legacy one has reached end of life, so it's not really a viable solution on the long term.
EDIT: Alright, the original author wording lacked precision: this has nothing to do with the combined use of Qt and mongo-cxx-driver.
The problem is due to linking to a certain version of the mongo-cxx library, while using the includes for another version.Turns out I had already installed mongocxx elsewhere, and the CMake package files for mongo-cxx-driver seem to have some issue finding the include files on its own, so that issue might happen if you're not careful enough and mess up the include part.
-
Hello,
If you want an easier integration with Qt and MongoDB, you can try QxOrm library.
The documentation can be found here.
And here is a project example on GitHub.Please note that the latest commit on GitHub for QxOrm library supports Qt6.