Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create Qt 6.5 mysql driver with cmake?
Forum Updated to NodeBB v4.3 + New Features

How to create Qt 6.5 mysql driver with cmake?

Scheduled Pinned Locked Moved Unsolved General and Desktop
60 Posts 8 Posters 9.8k Views 3 Watching
  • 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.
  • S Saad02

    @JonB Done and nothing much happened.
    3085b636-941b-46f4-915e-58c3cfa84a4d-image.png
    Application Output:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL

    Compile Output:
    18:27:06: Running steps for project database...
    18:27:06: Starting: "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" "C:\Users\Saad\Documents\qt c++\database\database.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
    18:27:10: The process "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" exited normally.
    18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -f "C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug/Makefile" qmake_all
    mingw32-make: Nothing to be done for 'qmake_all'.
    18:27:10: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
    18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j4
    C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
    mingw32-make[1]: Nothing to be done for 'first'.
    mingw32-make[1]: Leaving directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
    18:27:11: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
    18:27:11: Elapsed time: 00:05.

    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by
    #36

    @Saad02
    I can only say that, although you seem to have done the right thing, this is not correct output when setting QT_DEBUG_PLUGINS=1. You can verify that by searching the hundreds of occasions it has been used in this forum's questions or on the web.

    Since I don't know exactly about Creator I suggest you set it in a shell and run your executable from there.

    JonBJ 1 Reply Last reply
    0
    • S Saad02

      @JonB Done and nothing much happened.
      3085b636-941b-46f4-915e-58c3cfa84a4d-image.png
      Application Output:
      QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL

      Compile Output:
      18:27:06: Running steps for project database...
      18:27:06: Starting: "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" "C:\Users\Saad\Documents\qt c++\database\database.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
      18:27:10: The process "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" exited normally.
      18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -f "C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug/Makefile" qmake_all
      mingw32-make: Nothing to be done for 'qmake_all'.
      18:27:10: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
      18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j4
      C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug
      mingw32-make[1]: Entering directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
      mingw32-make[1]: Nothing to be done for 'first'.
      mingw32-make[1]: Leaving directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
      18:27:11: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
      18:27:11: Elapsed time: 00:05.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #37

      @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

      Application Output:

      There should be more output if QT_DEBUG_PLUGINS was set - is that really all you get?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

        Application Output:

        There should be more output if QT_DEBUG_PLUGINS was set - is that really all you get?

        S Offline
        S Offline
        Saad02
        wrote on last edited by Saad02
        #38

        @jsulm Yes, sir.
        7c800bc0-1b62-477b-ac5b-799c2abdac38-image.png

        Should I shift to qt 5, since it's easier to create one for qt as it uses qmake? And if I do, then what will I miss there?

        1 Reply Last reply
        0
        • JonBJ JonB

          @Saad02
          I can only say that, although you seem to have done the right thing, this is not correct output when setting QT_DEBUG_PLUGINS=1. You can verify that by searching the hundreds of occasions it has been used in this forum's questions or on the web.

          Since I don't know exactly about Creator I suggest you set it in a shell and run your executable from there.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #39

          @Saad02

          @JonB said in How to create Qt 6.5 mysql driver with cmake?:

          Since I don't know exactly about Creator I suggest you set it [set QT_DEBUG_PLUGINS=1] in a shell and run your executable from there.

          Did you try this? You have to know how to run your executable outside of Creator, else it will be useless in the the long-term, you cannot always require your code to run inside Creator!

          S 1 Reply Last reply
          0
          • JonBJ JonB

            @Saad02

            @JonB said in How to create Qt 6.5 mysql driver with cmake?:

            Since I don't know exactly about Creator I suggest you set it [set QT_DEBUG_PLUGINS=1] in a shell and run your executable from there.

            Did you try this? You have to know how to run your executable outside of Creator, else it will be useless in the the long-term, you cannot always require your code to run inside Creator!

            S Offline
            S Offline
            Saad02
            wrote on last edited by
            #40

            @JonB Isn't this what he meant-
            a89c4f06-cd5e-4ab2-ba93-192b7df7bc53-image.png
            Please let me know if I have run it in the wrong terminal.

            JonBJ 1 Reply Last reply
            0
            • S Saad02

              @JonB Isn't this what he meant-
              a89c4f06-cd5e-4ab2-ba93-192b7df7bc53-image.png
              Please let me know if I have run it in the wrong terminal.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #41

              @Saad02 Yes, that is right, now you have to run your program from there.

              S 1 Reply Last reply
              0
              • JonBJ JonB

                @Saad02 Yes, that is right, now you have to run your program from there.

                S Offline
                S Offline
                Saad02
                wrote on last edited by Saad02
                #42

                @JonB Sir, I did it before and now again but nothing changed.

                JonBJ 1 Reply Last reply
                0
                • S Saad02

                  @JonB Sir, I did it before and now again but nothing changed.

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by
                  #43

                  @Saad02
                  I wish you would show a screenshot of what you do in that terminal immediately after the set QT_DEBUG_PLUGINS=1....

                  If you read through this forum or search the web you will find "hundreds" of occasions where people get a

                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
                  

                  and they set the environment variable, run their application and get diagnostic output as to why it has failed to load QMYSQL driver. Not one of them has ever reported it failed to produce the diagnostic output. I find it hard to believe your case is any different.....

                  S 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Saad02
                    I wish you would show a screenshot of what you do in that terminal immediately after the set QT_DEBUG_PLUGINS=1....

                    If you read through this forum or search the web you will find "hundreds" of occasions where people get a

                    QSqlDatabase: QMYSQL driver not loaded
                    QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
                    

                    and they set the environment variable, run their application and get diagnostic output as to why it has failed to load QMYSQL driver. Not one of them has ever reported it failed to produce the diagnostic output. I find it hard to believe your case is any different.....

                    S Offline
                    S Offline
                    Saad02
                    wrote on last edited by
                    #44

                    @JonB Ok, I am providing you the screenshots.
                    68b493b8-88e8-477d-9be2-172c8e73a9b0-image.png
                    ed6f437b-7639-4bbd-975d-ebec8f2438dd-image.png
                    c8c93efd-d9e5-4721-a1c2-804f1eca13b8-image.png
                    (Rest of the tabs are empty)
                    This site is not allowing me to upload full screenshots. That's why I cropped and uploaded these.

                    JonBJ T 2 Replies Last reply
                    0
                    • S Saad02

                      @JonB Ok, I am providing you the screenshots.
                      68b493b8-88e8-477d-9be2-172c8e73a9b0-image.png
                      ed6f437b-7639-4bbd-975d-ebec8f2438dd-image.png
                      c8c93efd-d9e5-4721-a1c2-804f1eca13b8-image.png
                      (Rest of the tabs are empty)
                      This site is not allowing me to upload full screenshots. That's why I cropped and uploaded these.

                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by JonB
                      #45

                      @Saad02
                      I already suggested you run this in a terminal, not in Creator, so we can see what is going on. Repeatedly showing it is not working from your Creator isn't getting us anywhere.

                      I don't know why you don't see the diagnostic output in Creator.
                      It occurs to me: when run in terminal I am not sure where you get the diagnostic output under Windows. It may not be in terminal, may have to go to some debugger. You can probably search the forum or elsewhere, I don't use Windows for Qt. Otherwise I leave someone else to suggest.

                      S 1 Reply Last reply
                      0
                      • S Saad02

                        @JonB Ok, I am providing you the screenshots.
                        68b493b8-88e8-477d-9be2-172c8e73a9b0-image.png
                        ed6f437b-7639-4bbd-975d-ebec8f2438dd-image.png
                        c8c93efd-d9e5-4721-a1c2-804f1eca13b8-image.png
                        (Rest of the tabs are empty)
                        This site is not allowing me to upload full screenshots. That's why I cropped and uploaded these.

                        T Offline
                        T Offline
                        thecodemonkey
                        wrote on last edited by
                        #46

                        @Saad02 could you show us some code you're running? You may edit out sensitive data like passwords etc. For example, if I remove a line like

                        QSqlDatabase sqlConn = QSqlDatabase::addDatabase(QStringLiteral("QMYSQL"));
                        

                        then there's no QMYSQL plugin debug output despite QT_DEBUG_PLUGINS

                        1 Reply Last reply
                        0
                        • JonBJ JonB

                          @Saad02
                          I already suggested you run this in a terminal, not in Creator, so we can see what is going on. Repeatedly showing it is not working from your Creator isn't getting us anywhere.

                          I don't know why you don't see the diagnostic output in Creator.
                          It occurs to me: when run in terminal I am not sure where you get the diagnostic output under Windows. It may not be in terminal, may have to go to some debugger. You can probably search the forum or elsewhere, I don't use Windows for Qt. Otherwise I leave someone else to suggest.

                          S Offline
                          S Offline
                          Saad02
                          wrote on last edited by
                          #47

                          @JonB This is what I did after running "set QT_EBUG_PLUGINS=1" on the terminal. I have no idea about it if u r saying me to run that application directly from the terminal. Sorry :)

                          JonBJ mzimmersM 2 Replies Last reply
                          0
                          • S Saad02

                            @JonB This is what I did after running "set QT_EBUG_PLUGINS=1" on the terminal. I have no idea about it if u r saying me to run that application directly from the terminal. Sorry :)

                            JonBJ Online
                            JonBJ Online
                            JonB
                            wrote on last edited by
                            #48

                            @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                            I have no idea about it if u r saying me to run that application directly from the terminal. Sorry :)

                            Then you should as a developer. Just type the path to the executable.

                            S 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                              I have no idea about it if u r saying me to run that application directly from the terminal. Sorry :)

                              Then you should as a developer. Just type the path to the executable.

                              S Offline
                              S Offline
                              Saad02
                              wrote on last edited by
                              #49

                              @JonB Sir, can you please be more specific?

                              1 Reply Last reply
                              0
                              • S Saad02

                                @JonB This is what I did after running "set QT_EBUG_PLUGINS=1" on the terminal. I have no idea about it if u r saying me to run that application directly from the terminal. Sorry :)

                                mzimmersM Offline
                                mzimmersM Offline
                                mzimmers
                                wrote on last edited by
                                #50

                                @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                                I have no idea about it if u r saying me to run that application directly from the terminal.

                                Yes, that's what he's asking for (I believe):

                                From a terminal window:

                                • go to the folder with your executable
                                • enter "./<your executable filename>
                                • hit return
                                • post the output
                                JonBJ 1 Reply Last reply
                                0
                                • mzimmersM mzimmers

                                  @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                                  I have no idea about it if u r saying me to run that application directly from the terminal.

                                  Yes, that's what he's asking for (I believe):

                                  From a terminal window:

                                  • go to the folder with your executable
                                  • enter "./<your executable filename>
                                  • hit return
                                  • post the output
                                  JonBJ Online
                                  JonBJ Online
                                  JonB
                                  wrote on last edited by
                                  #51

                                  @Saad02
                                  Following @mzimmers steps, don't forget to type the set QT_DEBUG_PLUGINS=1 before running your executable, else it's all a waste of time....

                                  S 1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @Saad02
                                    Following @mzimmers steps, don't forget to type the set QT_DEBUG_PLUGINS=1 before running your executable, else it's all a waste of time....

                                    S Offline
                                    S Offline
                                    Saad02
                                    wrote on last edited by
                                    #52

                                    @JonB Sir, is it ok, now?
                                    ea7107bf-8bfe-46dd-9033-c812400dd6c0-image.png

                                    JonBJ 1 Reply Last reply
                                    0
                                    • S Saad02

                                      @JonB Sir, is it ok, now?
                                      ea7107bf-8bfe-46dd-9033-c812400dd6c0-image.png

                                      JonBJ Online
                                      JonBJ Online
                                      JonB
                                      wrote on last edited by
                                      #53

                                      @Saad02
                                      Yes, what you finally show is what we wanted to see tested.

                                      But now I don't understand. OK, it does not show the verbose diagnostic output expected from set QT_DEBUG_PLUGINS=1, that is "surprising". However, it does not show the

                                      QSqlDatabase: QMYSQL driver not loaded
                                      QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
                                      

                                      from your earlier screenshot either. And I think you are saying the database driver still does not load, so you should get that at least.

                                      I did say earlier: I am not a Windows Qt user, but

                                      It occurs to me: when run in terminal I am not sure where you get the diagnostic output under Windows. It may not be in terminal, may have to go to some debugger. You can probably search the forum or elsewhere, I don't use Windows for Qt. Otherwise I leave someone else to suggest.

                                      It may be that under Windows you do not get diagnostic output in the terminal when launching from there. You will have to search the forum or Google for this, or wait for someone else to comment.

                                      S 1 Reply Last reply
                                      0
                                      • JonBJ JonB

                                        @Saad02
                                        Yes, what you finally show is what we wanted to see tested.

                                        But now I don't understand. OK, it does not show the verbose diagnostic output expected from set QT_DEBUG_PLUGINS=1, that is "surprising". However, it does not show the

                                        QSqlDatabase: QMYSQL driver not loaded
                                        QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
                                        

                                        from your earlier screenshot either. And I think you are saying the database driver still does not load, so you should get that at least.

                                        I did say earlier: I am not a Windows Qt user, but

                                        It occurs to me: when run in terminal I am not sure where you get the diagnostic output under Windows. It may not be in terminal, may have to go to some debugger. You can probably search the forum or elsewhere, I don't use Windows for Qt. Otherwise I leave someone else to suggest.

                                        It may be that under Windows you do not get diagnostic output in the terminal when launching from there. You will have to search the forum or Google for this, or wait for someone else to comment.

                                        S Offline
                                        S Offline
                                        Saad02
                                        wrote on last edited by
                                        #54

                                        @JonB Ok, I understand!
                                        it is not visible in the terminal- "QSqlDatabase: QMYSQL driver not loaded
                                        QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL" but I can see it in Qt creator?
                                        Should I wait any longer or shift to qt 5 as it uses qmake and has an easier process to create a MySQL driver for qt?

                                        JonBJ 1 Reply Last reply
                                        0
                                        • S Saad02

                                          @JonB Ok, I understand!
                                          it is not visible in the terminal- "QSqlDatabase: QMYSQL driver not loaded
                                          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL" but I can see it in Qt creator?
                                          Should I wait any longer or shift to qt 5 as it uses qmake and has an easier process to create a MySQL driver for qt?

                                          JonBJ Online
                                          JonBJ Online
                                          JonB
                                          wrote on last edited by
                                          #55

                                          @Saad02
                                          https://forum.qt.io/topic/41943/platform-plugin-windows/8 from 2014(!) says:

                                          Hi, just an update on why QT_DEBUG_PLUGINS=1 doesn't work as expected when you launch a Qt app from the command line (as it does on Linux and Macs): I found that for Windows MSVC and MinGW compilers, Qt routes the texts to OutputDebugString(), that's why the CMD window shows no output.

                                          Instead, to see the output, download "Sysinternal's DbgView":http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

                                          That link still seems valid. You could try downloading it and setting it up to see if you can get the output. Or @hskoglund goes through steps there to make it work in Creator you could try following that precisely.

                                          Or you could try setting it in your source code. As the very first statement in main(), before you create any QApplication or whatever instance, try inserting:

                                          putenv("QT_DEBUG_PLUGINS=1");
                                          

                                          (You may need to #include <stdlib.h> or whatever for MinGW.) Then if you run for debug in Qt Creator you may/ought find it produces the diagnostic output in the Application Output pane.

                                          As for changing from Qt6 to Qt5. Although I am quite happy with Qt5, it is probably a big step for you to "downgrade" from the latest major release in the hope of resolving some issue. And there is no guarantee it won't behave just the same under Qt5.

                                          For now I would pursue my suggestions above to try to get the diagnostic output.

                                          S 1 Reply Last reply
                                          0

                                          • Login

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