Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL)
Forum Updated to NodeBB v4.3 + New Features

Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL)

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
33 Posts 6 Posters 4.1k Views 1 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.
  • L Lestev
    23 Feb 2022, 07:03

    @SGaist So i followed documentation :
    Screenshot 2022-02-23 at 10.00.44.png

    Screenshot 2022-02-23 at 10.00.16.png

    but the command gave me an error

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 23 Feb 2022, 07:12 last edited by
    #15

    @Lestev You should really start to CAREFULLY read what others write and also try to understand what you are doing!
    You are still using .<so|dylib> in your command and it should be actually apparent that you should replace it by what your platform requires (.dylib on Mac).

    You also should remove "-G Ninja" if you do not have Ninja.

    Also you were asked to post TEXT not pictures, but you keep posting pictures. Is there a reason for that?

    L 1 Reply Last reply 23 Feb 2022, 08:13
    1
    • J jsulm
      23 Feb 2022, 07:12

      @Lestev You should really start to CAREFULLY read what others write and also try to understand what you are doing!
      You are still using .<so|dylib> in your command and it should be actually apparent that you should replace it by what your platform requires (.dylib on Mac).

      You also should remove "-G Ninja" if you do not have Ninja.

      Also you were asked to post TEXT not pictures, but you keep posting pictures. Is there a reason for that?

      L Offline
      L Offline
      Lestev
      wrote on 23 Feb 2022, 08:13 last edited by
      #16

      @jsulm wow! Thank you very much, I did this and succeeded, but the error remained, I added install_name_tool -change /usr/local/mysql-8.0.25-macos11-x86_64/lib/libmysqlclient.21.dylib /usr/local/mysql-8.0 . 25-macos11-x86_64/lib/libmysqlclient.21.dylib/Users/migellestv/Qt/6.2.3/macos/plugins/sqldrivers/libqsqlmysql.dylib

      and I succeeded, but error remained:

      QSqlQuery::exec: database not open
      QSqlQuery::exec: database not open
      QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

      Why if i added install_name_tool?

      J 1 Reply Last reply 23 Feb 2022, 08:22
      0
      • L Lestev
        23 Feb 2022, 08:13

        @jsulm wow! Thank you very much, I did this and succeeded, but the error remained, I added install_name_tool -change /usr/local/mysql-8.0.25-macos11-x86_64/lib/libmysqlclient.21.dylib /usr/local/mysql-8.0 . 25-macos11-x86_64/lib/libmysqlclient.21.dylib/Users/migellestv/Qt/6.2.3/macos/plugins/sqldrivers/libqsqlmysql.dylib

        and I succeeded, but error remained:

        QSqlQuery::exec: database not open
        QSqlQuery::exec: database not open
        QSqlDatabase: QMYSQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QODBC QPSQL

        Why if i added install_name_tool?

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 23 Feb 2022, 08:22 last edited by
        #17

        @Lestev Did you also do this:

        cmake --build .
        cmake --install .
        

        ?
        https://doc.qt.io/qt-6/sql-driver.html#qmysql

        L 1 Reply Last reply 23 Feb 2022, 09:02
        0
        • J jsulm
          23 Feb 2022, 08:22

          @Lestev Did you also do this:

          cmake --build .
          cmake --install .
          

          ?
          https://doc.qt.io/qt-6/sql-driver.html#qmysql

          L Offline
          L Offline
          Lestev
          wrote on 23 Feb 2022, 09:02 last edited by
          #18

          @jsulm said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):

          Did you also do this:

          Yes i successed :

          cmake --build .
          [9/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib
          ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib
          [11/11] Linking CXX shared module plugins/sqldrivers/libqsqlite.dylib
          migellestev@Migels-MacBook-Pro build-sqldrivers % cmake --install .
          -- Install configuration: "RelWithDebInfo"
          -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
          -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
          -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
          etc

          J 1 Reply Last reply 23 Feb 2022, 09:13
          0
          • L Lestev
            23 Feb 2022, 09:02

            @jsulm said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):

            Did you also do this:

            Yes i successed :

            cmake --build .
            [9/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib
            ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib
            [11/11] Linking CXX shared module plugins/sqldrivers/libqsqlite.dylib
            migellestev@Migels-MacBook-Pro build-sqldrivers % cmake --install .
            -- Install configuration: "RelWithDebInfo"
            -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
            -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
            -- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
            etc

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 23 Feb 2022, 09:13 last edited by
            #19

            @Lestev OK, then we need to debug now.
            Do this on console:

            • Go to the build folder of your application
            • Do: export QT_DEBUG_PLUGINS=1
            • Run your app from the terminal
            • Copy paste the output from terminal to here

            You can also set QT_DEBUG_PLUGINS in Run settings of your project in QtCreator.
            https://doc.qt.io/qt-5/debug.html

            L 1 Reply Last reply 23 Feb 2022, 09:52
            0
            • J jsulm
              23 Feb 2022, 09:13

              @Lestev OK, then we need to debug now.
              Do this on console:

              • Go to the build folder of your application
              • Do: export QT_DEBUG_PLUGINS=1
              • Run your app from the terminal
              • Copy paste the output from terminal to here

              You can also set QT_DEBUG_PLUGINS in Run settings of your project in QtCreator.
              https://doc.qt.io/qt-5/debug.html

              L Offline
              L Offline
              Lestev
              wrote on 23 Feb 2022, 09:52 last edited by Lestev
              #20

              @jsulm Thanks, i get it, but how i can use run in terminal project?, i wrote:

              migellestev@Migels-MacBook-Pro forBeginner % c++ main.cpp
              main.cpp:1:10: fatal error: 'QGuiApplication' file not found
              #include <QGuiApplication>
              ^~~~~~~~~~~~~~~~~
              1 error generated.

              J 2 Replies Last reply 23 Feb 2022, 09:55
              0
              • L Lestev
                23 Feb 2022, 09:52

                @jsulm Thanks, i get it, but how i can use run in terminal project?, i wrote:

                migellestev@Migels-MacBook-Pro forBeginner % c++ main.cpp
                main.cpp:1:10: fatal error: 'QGuiApplication' file not found
                #include <QGuiApplication>
                ^~~~~~~~~~~~~~~~~
                1 error generated.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 23 Feb 2022, 09:55 last edited by
                #21
                This post is deleted!
                1 Reply Last reply
                0
                • L Lestev
                  23 Feb 2022, 09:52

                  @jsulm Thanks, i get it, but how i can use run in terminal project?, i wrote:

                  migellestev@Migels-MacBook-Pro forBeginner % c++ main.cpp
                  main.cpp:1:10: fatal error: 'QGuiApplication' file not found
                  #include <QGuiApplication>
                  ^~~~~~~~~~~~~~~~~
                  1 error generated.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 23 Feb 2022, 09:57 last edited by
                  #22

                  @Lestev I did not ask you to build your app in the terminal, that you can still do in QtCreator.
                  What I asked you to do is to run the executable of your application.

                  L 1 Reply Last reply 23 Feb 2022, 15:14
                  0
                  • J jsulm
                    23 Feb 2022, 09:57

                    @Lestev I did not ask you to build your app in the terminal, that you can still do in QtCreator.
                    What I asked you to do is to run the executable of your application.

                    L Offline
                    L Offline
                    Lestev
                    wrote on 23 Feb 2022, 15:14 last edited by
                    #23

                    @jsulm hey, the terminal doesn't output anything, it only launches the application

                    migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug % export QT_DEBUG_PLUGINS=1
                    migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug % open forBeginner.app
                    migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug %

                    Everything works, but inside qt error is keeping

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 23 Feb 2022, 20:40 last edited by
                      #24

                      Don't call open, use the full path to the executable in the bundle.

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

                      L 1 Reply Last reply 24 Feb 2022, 18:25
                      0
                      • S SGaist
                        23 Feb 2022, 20:40

                        Don't call open, use the full path to the executable in the bundle.

                        L Offline
                        L Offline
                        Lestev
                        wrote on 24 Feb 2022, 18:25 last edited by
                        #25

                        @SGaist hi, I think my directory is not properly defined because it should be /Users/migellestev/Qt/6.2.3/macos/plugins/sqldrivers
                        but directory is:
                        /Users/migellestev/Qt/QtDesignStudio/qt6_design_studio_reduced_version/plugins/sqldrivers

                        if it helps:
                        Screenshot 2022-02-24 at 21.23.40.png
                        Screenshot 2022-02-24 at 21.24.05.png

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on 24 Feb 2022, 18:28 last edited by
                          #26

                          Looks like you're mixing up Qt versions which is not possible. Make sure QtDesignStudio is not picked up, only your Qt6.2.2 where you also (hopefully) build your Qt mysql plugin for. Currently it looks like you created (or had by default - don't know) the plugin inside QtDesignStudio.

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          L 1 Reply Last reply 28 Feb 2022, 04:07
                          0
                          • C Christian Ehrlicher
                            24 Feb 2022, 18:28

                            Looks like you're mixing up Qt versions which is not possible. Make sure QtDesignStudio is not picked up, only your Qt6.2.2 where you also (hopefully) build your Qt mysql plugin for. Currently it looks like you created (or had by default - don't know) the plugin inside QtDesignStudio.

                            L Offline
                            L Offline
                            Lestev
                            wrote on 28 Feb 2022, 04:07 last edited by
                            #27

                            @Christian-Ehrlicher
                            Thanks for your response very much,
                            But i verify my path and got that this path used by default, but why?

                            Screenshot 2022-02-28 at 07.03.14.png

                            I reinstalled qt and got the same

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on 28 Feb 2022, 16:16 last edited by
                              #28

                              Don't know MacOS but on linux this means you have the other somewhere in your LD_LIBRARY_PATH or ld.so.conf. Remove it /make sure the correct path comes first.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              1 Reply Last reply
                              0
                              • I Offline
                                I Offline
                                Ilya Pro
                                wrote on 5 Mar 2022, 16:37 last edited by Ilya Pro 3 May 2022, 16:37
                                #29

                                Hello!
                                Error
                                /Users/ilaproskurnev/Qt/6.2.3/macos/bin/qt-cmake: line 17: exec: cmake: not found
                                If export PATH="/Users/ilaproskurnev/Qt/6.2.3/macos/bin:$PATH"
                                qt-cmake -G Ninja /Users/ilaproskurnev/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/ilaproskurnev/Qt/6.2.3/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib"
                                line 17: exec: cmake: not found

                                1 Reply Last reply
                                0
                                • C Offline
                                  C Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on 5 Mar 2022, 16:51 last edited by
                                  #30

                                  Then make sure that cmake is installed and in your PATH...

                                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                  Visit the Qt Academy at https://academy.qt.io/catalog

                                  I 1 Reply Last reply 5 Mar 2022, 17:08
                                  0
                                  • C Christian Ehrlicher
                                    5 Mar 2022, 16:51

                                    Then make sure that cmake is installed and in your PATH...

                                    I Offline
                                    I Offline
                                    Ilya Pro
                                    wrote on 5 Mar 2022, 17:08 last edited by Ilya Pro 3 May 2022, 17:11
                                    #31

                                    @Christian-Ehrlicher
                                    Please tell me how to check it?
                                    exec "$cmake_path" -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" "$@"

                                    C 1 Reply Last reply 5 Mar 2022, 17:12
                                    0
                                    • I Ilya Pro
                                      5 Mar 2022, 17:08

                                      @Christian-Ehrlicher
                                      Please tell me how to check it?
                                      exec "$cmake_path" -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" "$@"

                                      C Offline
                                      C Offline
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on 5 Mar 2022, 17:12 last edited by
                                      #32

                                      @Ilya-Pro said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):

                                      Please tell me how to check it?

                                      I don't understand. If you want to build Qt or one of it's plugins you have to install cmake and make sure it's found in your PATH.

                                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                      Visit the Qt Academy at https://academy.qt.io/catalog

                                      I 1 Reply Last reply 5 Mar 2022, 17:20
                                      0
                                      • C Christian Ehrlicher
                                        5 Mar 2022, 17:12

                                        @Ilya-Pro said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):

                                        Please tell me how to check it?

                                        I don't understand. If you want to build Qt or one of it's plugins you have to install cmake and make sure it's found in your PATH.

                                        I Offline
                                        I Offline
                                        Ilya Pro
                                        wrote on 5 Mar 2022, 17:20 last edited by Ilya Pro 3 May 2022, 17:32
                                        #33

                                        @Christian-Ehrlicher
                                        QtToolchainHelpers.cmake
                                        toolchain_path="$script_dir_path/../lib/cmake/Qt6/qt.toolchain.cmake"
                                        screenshot

                                        1 Reply Last reply
                                        0

                                        24/33

                                        23 Feb 2022, 20:40

                                        • Login

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