Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Downloading MongoDB Drivers to use in QT

Downloading MongoDB Drivers to use in QT

Scheduled Pinned Locked Moved Solved 3rd Party Software
mongocxxmongodbc++
11 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by SGaist
    #2

    Hi,

    On which OS are you ?

    In any case, AFAIK, you need libbson to write client applications.

    There's no Qt driver for NoSQL database so you have to write the client side yourself.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    O 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      On which OS are you ?

      In any case, AFAIK, you need libbson to write client applications.

      There's no Qt driver for NoSQL database so you have to write the client side yourself.

      O Offline
      O Offline
      orsini29
      wrote on last edited by
      #3

      @SGaist

      Hi,

      @SGaist said in Downloading MongoDB Drivers to use in QT:

      On which OS are you ?

      Windows 10.

      @SGaist said in Downloading MongoDB Drivers to use in QT:

      There's no Qt driver for NoSQL database so you have to write the client side yourself.

      Sorry if this is a silly question, but by writing the client side myself what exactly do you mean? Basically all the operations of insertion, updating, deleting, etc.?

      The goal is to have an application connected to a cloud database (SQL or NoSQL). The only reason I chose MongoDB Atlas (the cloud version), is because I have far more experience in mongo vs any other DB, as well I know MongoDB Atlas has free tiers in which I can just use them for project like so, rather than having to purchase a plan for another cloud DB.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        What I meant is that there's no abstraction for NoSQL as there is for SQL. With the Qt SQL module, you basically open the connection and then write your queries.

        You don't have the same option with NoSQL so you will have to write stuff like described in the MongoDB C++ tutorial. That's what I meant by client side.

        By the way, I was wrong about libbson, I have mixed it with a different library, sorry.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        O 1 Reply Last reply
        1
        • SGaistS SGaist

          What I meant is that there's no abstraction for NoSQL as there is for SQL. With the Qt SQL module, you basically open the connection and then write your queries.

          You don't have the same option with NoSQL so you will have to write stuff like described in the MongoDB C++ tutorial. That's what I meant by client side.

          By the way, I was wrong about libbson, I have mixed it with a different library, sorry.

          O Offline
          O Offline
          orsini29
          wrote on last edited by
          #5

          @SGaist

          @SGaist said in Downloading MongoDB Drivers to use in QT:

          What I meant is that there's no abstraction for NoSQL as there is for SQL. With the Qt SQL module, you basically open the connection and then write your queries.

          Okay, thank you for clarifying this.

          As for the link you had sent, I have not come across that one yet, surprisingly from all the ones I have been looking at, and I will take a look. Although, with the one I had followed I ran CMake on my TAR downloaded from the link (here), and I got a bunch of Visual Code files. I was a bit confused how this would be used in Qt, or if I was supposed to run a qmake on it or something... I am using MinGw32 for the compiler, maybe I need to switch to MSVC if I were to do this?

          SGaistS 1 Reply Last reply
          0
          • O orsini29

            @SGaist

            @SGaist said in Downloading MongoDB Drivers to use in QT:

            What I meant is that there's no abstraction for NoSQL as there is for SQL. With the Qt SQL module, you basically open the connection and then write your queries.

            Okay, thank you for clarifying this.

            As for the link you had sent, I have not come across that one yet, surprisingly from all the ones I have been looking at, and I will take a look. Although, with the one I had followed I ran CMake on my TAR downloaded from the link (here), and I got a bunch of Visual Code files. I was a bit confused how this would be used in Qt, or if I was supposed to run a qmake on it or something... I am using MinGw32 for the compiler, maybe I need to switch to MSVC if I were to do this?

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            The goal is not that you integrate their code into your project but that you build their libraries and then use them in your code.

            Based one the article they seem to use Visual Studio but you can try with MinGW by modifying the tool in their configuration example.

            Note that they use cmake as project management tool. I would advise to do the same for your project as qmake is now deprecated. It can still be used for client projects but the Qt framework has switch to cmake for its build system.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            O 1 Reply Last reply
            1
            • SGaistS SGaist

              The goal is not that you integrate their code into your project but that you build their libraries and then use them in your code.

              Based one the article they seem to use Visual Studio but you can try with MinGW by modifying the tool in their configuration example.

              Note that they use cmake as project management tool. I would advise to do the same for your project as qmake is now deprecated. It can still be used for client projects but the Qt framework has switch to cmake for its build system.

              O Offline
              O Offline
              orsini29
              wrote on last edited by
              #7

              @SGaist said in Downloading MongoDB Drivers to use in QT:

              The goal is not that you integrate their code into your project but that you build their libraries and then use them in your code.

              Yes, correct.

              So I got a little further with some research and following along with the tutorial. Although, I am still a little stuck and was wondering if you can steer me in the right direction, although if you aren't able to I understand as this is not exactly Qt related.

              I have this folder path in my C drive (pictured below). In the include folder it has the header files, for both libmongoc-1.0 and libbson-1.0. (so you might have been correct in your previous comment). Then the lib directory has these, pictured below.

              a28b9080-e517-4487-a15f-0a80e55dbf80-image.png

              7d30b010-3cb9-4ee2-9ea9-347bd642d931-image.png

              I added this into my *.pro file, and it builds fine.

              LIBS += C:/mongo-c-driver/lib/mongoc-1.0.lib

              Although once I go to use #include <mongoc/mongoc.h> I get an error saying the file cannot be found, which makes sense obviously because the file is not in that relative path.

              If I plan on packaging this application to be used on another desktop, how would I go about including the headers, along with the lib file to be used? I know that including the headers within the code is not the answer, as you had stated below.

              @SGaist said in Downloading MongoDB Drivers to use in QT:

              The goal is not that you integrate their code into your project but that you build their libraries and then use them in your code.

              I will be looking into this in the meantime, and update my comment if I end up figuring this out. I have a feeling it is something simple I am completely overlooking. Thanks again @SGaist.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                You are missing the -l before the lib path.

                In the absolute your should have something like:

                LIBS += -LC:/mongo-c-driver/lib/ -lmongoc-1.0
                INCLUDEPATH += C:/mongo-c-driver/include/
                

                As for distributing your application, you don't need the header files at all. You just have to distribute the libraries if you use the dynamic version.

                On an unrelated note, you should also consider moving your project management to cmake. qmake is now legacy from a Qt point of view and projects are encouraged to use cmake in its place.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                O 1 Reply Last reply
                1
                • SGaistS SGaist

                  You are missing the -l before the lib path.

                  In the absolute your should have something like:

                  LIBS += -LC:/mongo-c-driver/lib/ -lmongoc-1.0
                  INCLUDEPATH += C:/mongo-c-driver/include/
                  

                  As for distributing your application, you don't need the header files at all. You just have to distribute the libraries if you use the dynamic version.

                  On an unrelated note, you should also consider moving your project management to cmake. qmake is now legacy from a Qt point of view and projects are encouraged to use cmake in its place.

                  O Offline
                  O Offline
                  orsini29
                  wrote on last edited by orsini29
                  #9

                  @SGaist

                  @SGaist said in Downloading MongoDB Drivers to use in QT:

                  As for distributing your application, you don't need the header files at all. You just have to distribute the libraries if you use the dynamic version.

                  By dynamic version, I assume you mean using a DLL? I see DLLs within mongo-c-driver/bin, (see below). Would this just be as simple as putting the DLLs into the application path? Or would the header files be needed in this case? I know you said they would not be needed, although just a little confused on how else the function definitions would be referenced in that regard.

                  497dc8ed-a0d1-425f-a8b8-7bff3e9f29c9-image.png

                  @SGaist said in Downloading MongoDB Drivers to use in QT:

                  On an unrelated note, you should also consider moving your project management to cmake. qmake is now legacy from a Qt point of view and projects are encouraged to use cmake in its place.

                  As for this, I will definitely start migrating some stuff over. I have been using qmake ever since I started programming with Qt, so it will be a bit of a learning curve (again) on how to change everything over, so if you have any good information please let me know! Otherwise Google is my friend!

                  I will definitely be marking this topic as solved once I hear back from you. Unsure if the thread locks when it becomes solved. Thanks again!

                  Edit:

                  Also, would using cmake over qmake get rid of the *.pro file configuration? Or is that completely irrelevant?

                  SGaistS 1 Reply Last reply
                  0
                  • O orsini29

                    @SGaist

                    @SGaist said in Downloading MongoDB Drivers to use in QT:

                    As for distributing your application, you don't need the header files at all. You just have to distribute the libraries if you use the dynamic version.

                    By dynamic version, I assume you mean using a DLL? I see DLLs within mongo-c-driver/bin, (see below). Would this just be as simple as putting the DLLs into the application path? Or would the header files be needed in this case? I know you said they would not be needed, although just a little confused on how else the function definitions would be referenced in that regard.

                    497dc8ed-a0d1-425f-a8b8-7bff3e9f29c9-image.png

                    @SGaist said in Downloading MongoDB Drivers to use in QT:

                    On an unrelated note, you should also consider moving your project management to cmake. qmake is now legacy from a Qt point of view and projects are encouraged to use cmake in its place.

                    As for this, I will definitely start migrating some stuff over. I have been using qmake ever since I started programming with Qt, so it will be a bit of a learning curve (again) on how to change everything over, so if you have any good information please let me know! Otherwise Google is my friend!

                    I will definitely be marking this topic as solved once I hear back from you. Unsure if the thread locks when it becomes solved. Thanks again!

                    Edit:

                    Also, would using cmake over qmake get rid of the *.pro file configuration? Or is that completely irrelevant?

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    The header is only required when you develop your code. At runtime, it doesn't do anything. Your application is linked to the library.

                    Yes, it's the .dll that are required and yes again, you deploy them along with your application executable.

                    Yes, you will use a CMakeLists.txt file in place of the .pro file. There's a small helper script call qmake2cmake that you can use to get your porting effort started.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    O 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      The header is only required when you develop your code. At runtime, it doesn't do anything. Your application is linked to the library.

                      Yes, it's the .dll that are required and yes again, you deploy them along with your application executable.

                      Yes, you will use a CMakeLists.txt file in place of the .pro file. There's a small helper script call qmake2cmake that you can use to get your porting effort started.

                      O Offline
                      O Offline
                      orsini29
                      wrote on last edited by
                      #11

                      @SGaist

                      Awesome. Thank you a lot, appreciate the help. I will definitely be looking into this, and if I have any other questions I'll reach out, cheers!

                      1 Reply Last reply
                      0
                      • O orsini29 has marked this topic as solved on

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved