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 11.5k 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.
  • T thecodemonkey

    @Saad02 I don't see the output that is printed if the environment variable QT_DEBUG_PLUGINS=1 is set. Could you run the project as debug build?

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

    @thecodemonkey Nothing changed. I got the same output. Do I have to somewhere else except Qt Creator?

    jsulmJ 1 Reply Last reply
    0
    • S Saad02

      @thecodemonkey Nothing changed. I got the same output. Do I have to somewhere else except Qt Creator?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #26

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

      Do I have to somewhere else except Qt Creator?

      No, you just need to do it properly. You need to set QT_DEBUG_PLUGINS=1 in Run settings of your project in QtCreator.

      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?:

        Do I have to somewhere else except Qt Creator?

        No, you just need to do it properly. You need to set QT_DEBUG_PLUGINS=1 in Run settings of your project in QtCreator.

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

        @jsulm Sir, you mean that file with ".pro" extension right?
        database.pro:
        QT += core gui sql

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        CONFIG += c++17
        QT_DEBUG_PLUGINS=1

        You can make your code fail to compile if it uses deprecated APIs.

        In order to do so, uncomment the following line.

        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

        SOURCES +=
        main.cpp
        mainwindow.cpp

        HEADERS +=
        mainwindow.h

        FORMS +=
        mainwindow.ui

        Default rules for deployment.

        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /opt/$${TARGET}/bin
        !isEmpty(target.path): INSTALLS += target

        Nothing changed!

        jsulmJ 1 Reply Last reply
        0
        • S Saad02

          @jsulm Sir, you mean that file with ".pro" extension right?
          database.pro:
          QT += core gui sql

          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          CONFIG += c++17
          QT_DEBUG_PLUGINS=1

          You can make your code fail to compile if it uses deprecated APIs.

          In order to do so, uncomment the following line.

          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

          SOURCES +=
          main.cpp
          mainwindow.cpp

          HEADERS +=
          mainwindow.h

          FORMS +=
          mainwindow.ui

          Default rules for deployment.

          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target

          Nothing changed!

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #28

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

          you mean that file with ".pro" extension right?

          No, I did not say a single word about the pro file.
          You were asked to set QT_DEBUG_PLUGINS anvironment variable to 1 before starting your application.
          You can set it in QtCreator if you go to "Projects/Build & Run/Run/Run Environment".

          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?:

            you mean that file with ".pro" extension right?

            No, I did not say a single word about the pro file.
            You were asked to set QT_DEBUG_PLUGINS anvironment variable to 1 before starting your application.
            You can set it in QtCreator if you go to "Projects/Build & Run/Run/Run Environment".

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

            @jsulm Sir, I don't have "run environment" in run...
            ca4fc873-5149-4f0e-957d-519b7ba1b168-image.png

            jsulmJ 1 Reply Last reply
            0
            • S Saad02

              @jsulm Sir, I don't have "run environment" in run...
              ca4fc873-5149-4f0e-957d-519b7ba1b168-image.png

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #30

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

              I don't have "run environment" in run

              Of course you have, you just need to look bellow the part you posted, really...

              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?:

                I don't have "run environment" in run

                Of course you have, you just need to look bellow the part you posted, really...

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

                @jsulm Sir, the red marked one showing me my system variables, not run environment variable.
                1eb5abed-37d9-483e-bfc9-5ffbc2fcd279-image.png
                And this is the rest-
                c73f879f-e8bb-454a-a669-f902f1bbf016-image.png
                Here is all I have in "run".
                By the way, the internet connection in our local is currently unstable. Can it be the reason for that driver not to load?

                SGaistS 1 Reply Last reply
                0
                • S Saad02

                  @jsulm Sir, the red marked one showing me my system variables, not run environment variable.
                  1eb5abed-37d9-483e-bfc9-5ffbc2fcd279-image.png
                  And this is the rest-
                  c73f879f-e8bb-454a-a669-f902f1bbf016-image.png
                  Here is all I have in "run".
                  By the way, the internet connection in our local is currently unstable. Can it be the reason for that driver not to load?

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

                  @Saad02 do you see the arrow at the far right ? Click on it to show the variables.

                  Plugin loading and internet connection are unrelated

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

                  S 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    @Saad02 do you see the arrow at the far right ? Click on it to show the variables.

                    Plugin loading and internet connection are unrelated

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

                    @SGaist Sir, it is showing me my system variable. Not "run variable". I think I am doing something wrong. Should I reinstall QT? And what version should I install?
                    6a23905a-0075-44e0-856a-eb55bcbfb177-image.png

                    JonBJ 1 Reply Last reply
                    0
                    • S Saad02

                      @SGaist Sir, it is showing me my system variable. Not "run variable". I think I am doing something wrong. Should I reinstall QT? And what version should I install?
                      6a23905a-0075-44e0-856a-eb55bcbfb177-image.png

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

                      @Saad02
                      It seems to clearly show your Run environment, and that by default is the same as your System environment.

                      You have been asked to add a QT_DEBUG_PLUGINS environment variable into the Run environment, so do so.

                      Or, just run your executable from a terminal shell and add the environment variable there.

                      S 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Saad02
                        It seems to clearly show your Run environment, and that by default is the same as your System environment.

                        You have been asked to add a QT_DEBUG_PLUGINS environment variable into the Run environment, so do so.

                        Or, just run your executable from a terminal shell and add the environment variable there.

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

                        @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 jsulmJ 2 Replies 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.

                          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 Offline
                            jsulmJ Offline
                            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

                                          • Login

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