Mongoc_init (); crashed my QT app

Hi, i try to install mongo-c-driver in windows 10, the installation was successful, but when i try put in init code “mongoc_init();” the app is crashed. Currently i am working with QT Creator (QT 5.13), i need the help !!!

@Cesar_Cherre can you please provide information on the precise steps you took to install the C driver the complete error output from your program?

Yes,

  • Building on Visual Studio 2019
  • Version of mongocdriver : 1.16.2

$ cd mongo-c-driver-1.16.2
$ mkdir cmake-build
$ cd cmake-build
$ cmake -G “Visual Studio 16 2019 Win64” “-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver” “-DCMAKE_PREFIX_PATH=C:\mongo-c-driver” …

$ msbuild.exe /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj
$ msbuild.exe INSTALL.vcxproj

WhatsApp Image 2020-06-07 at 3.04.35 PM

  • set configuration LIB and INCLUDEPATH in QT Creator 5.13

LIBS += “C:\mongoc\lib\mongoc-1.0.lib”
INCLUDEPATH += “C:\mongoc\include\libmongoc-1.0”

LIBS += “C:\mongoc\lib\bson-1.0.lib”
INCLUDEPATH += “C:\mongoc\include\libbson-1.0”

  • the program never response and finally crashed.

I need some documentation, currently we are developing a vibrations analysis software, who needs store large float64 array in real time. My company is Vibrotechnology (Vibro Technology)

If your CMake command specifies the install prefix as -DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver and your QT creator configuration uses LIBS += “C:\mongoc\lib\mongoc-1.0.lib” then I think that you can fix the problem by changing your QT creator variable values to start with C:\mongo-c-driver instead of C:\mongoc.

I made a mistake in writing the post, I did it as you mentioned but I still don’t have the solution to the problem. I leave a simple code that I have done, as you will see, it doesn’t response.

So, when i commented the mongo commands, its response successfully

.

Tested with VIsual Studio, the same history.

@Cesar_Cherre Sorry for the delayed reply. I somehow missed the notification of your response. Are the unresolved external symbol errors the result of Visual Studio not being able to locate the libraries? When you build the console application, do you see any warnings from the compiler?

I didn’t see any notice from the compiler. But I already solved it, by chance I had the need to install an additional library, and I realized that it was quite similar, I took that concept to mongo c driver and it worked correctly with QT Creator and mingw64, I tried it with the executable distributing it in different platforms without problems.

That’s excellent news. Thanks for following up to say that the problem is resolved.

Hi Cesar_Cherre,

Can you show any document or Sample project how you achieve this…?

Hi Roberto_Sanchez,

Can you provide any sample project or documentation of how to connect MongoDB with QTCreator C++ application?