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. Getting crazy with "driver not loaded" mysql driver in windows 7 (mingw 32bit)

Getting crazy with "driver not loaded" mysql driver in windows 7 (mingw 32bit)

Scheduled Pinned Locked Moved General and Desktop
mysqldriverloadedreimpdlltoolcompiledpathplugindatabase
12 Posts 2 Posters 5.2k 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.
  • A Offline
    A Offline
    andrew87
    wrote on 29 Sept 2015, 21:13 last edited by
    #1

    Hello everybody!

    Sorry for my English, I don't speak or write often it.
    This is the third day that I'm struggling whit this plugin, before this post I have looked everywhere in this forum (and others), without find the solution.

    The code:

    db = new QSqlDatabase();
    qDebug() << "drivers:" db->drivers();
    db->setHostName("localhost");
    qDebug() << db->addDatabase("QMYSQL3");
    qDebug() << "Valid? "<< db->isValid();    // Returns true if connection exists
    qDebug() << db->lastError();
    

    And the output:

    drivers: ("QMYSQL", "QMYSQL3")
    QSqlDatabase(driver="QMYSQL3", database="", host="", port=-1, user="", open=false)
    Valid? false
    QSqlError("", "Driver not loaded", "Driver not loaded")

    I use it on Ubuntu with succes, but now, in windows it seems there's no way to make it work.
    I tried the prebuilt plugin, and also the compiled one from source code after watching a lot of tutorial, guide ecc.

    I already:

    • Added to the environment path (both in qt and in windows) of minwg "bin", mysql "lib" qt "bin" folder.
    • Copied libmysql.dll and mysqlclient.lib (from mysql directory) to each directory possible
    • Included mysql library directories to the project with:
      QMAKE_LIBDIR += "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
      LIBS += libmysql
    • tried with visual studio compiler version
    • installed and tried 4 different version of mysql (and XAMPP)
    • generated: libmysql.def and libmysql.a with reimp and dlltool command
    • the pointer to QSqlDatabase is allocated after QApplication has initialized

    As you can see, the qsqlmysql.dll driver is recognized but the driver isn't loaded, why?
    What should I have been wrong?

    A 1 Reply Last reply 30 Sept 2015, 13:11
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Sept 2015, 21:21 last edited by
      #2

      Hi and welcome to devnet,

      Please search the forum a bit, that question has already been asked many times.

      You likely don't have the MySQL client DLL not accessible through your PATH environment variable so it can be found and thus the driver fails to load. One simple way of changing this is to go to the Run part of the Project panel and modify the PATH environment variable by adding the path to the MySQL client DLLS containing folder.

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andrew87
        wrote on 29 Sept 2015, 21:34 last edited by
        #3

        Hello! Thank you for so fast reply.

        I looked a lot in the forum, I swear! Three days, maybe I'm no so much able to understand the procedures.
        So, I have already update the path (like I wrote in the first item point of my post):

        Screenshot

        Maybe I don't understand whatever I have to add, the test selectioned is the path of libmysql.lib, or not?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Sept 2015, 21:36 last edited by
          #4

          The question might be silly but are you sure that the DLLs (not the .lib files) are there ?

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

          A 1 Reply Last reply 29 Sept 2015, 21:42
          0
          • S SGaist
            29 Sept 2015, 21:36

            The question might be silly but are you sure that the DLLs (not the .lib files) are there ?

            A Offline
            A Offline
            andrew87
            wrote on 29 Sept 2015, 21:42 last edited by
            #5

            I hope that the only need dll is "libmysql.dll", if yes... so:

            Screenshot

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 29 Sept 2015, 21:45 last edited by
              #6

              Yes should be.

              So next step: add QT_DEBUG_PLUGINS 1 to the environment variable, you should see more information about what is happening at load time.

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

              A 1 Reply Last reply 29 Sept 2015, 21:49
              0
              • S SGaist
                29 Sept 2015, 21:45

                Yes should be.

                So next step: add QT_DEBUG_PLUGINS 1 to the environment variable, you should see more information about what is happening at load time.

                A Offline
                A Offline
                andrew87
                wrote on 29 Sept 2015, 21:49 last edited by
                #7

                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms" ...
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "minimal"
                ]
                },
                "className": "QMinimalIntegrationPlugin",
                "debug": false,
                "version": 328960
                }

                "The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
                not a plugin
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimald.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimald.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "minimal"
                ]
                },
                "className": "QMinimalIntegrationPlugin",
                "debug": true,
                "version": 328960
                }

                Got keys from plugin meta data ("minimal")
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "offscreen"
                ]
                },
                "className": "QOffscreenIntegrationPlugin",
                "debug": false,
                "version": 328960
                }

                "The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
                not a plugin
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreend.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreend.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "offscreen"
                ]
                },
                "className": "QOffscreenIntegrationPlugin",
                "debug": true,
                "version": 328960
                }

                Got keys from plugin meta data ("offscreen")
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "windows"
                ]
                },
                "className": "QWindowsIntegrationPlugin",
                "debug": false,
                "version": 328960
                }

                "The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
                not a plugin
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                "Keys": [
                "windows"
                ]
                },
                "className": "QWindowsIntegrationPlugin",
                "debug": true,
                "version": 328960
                }

                Got keys from plugin meta data ("windows")
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platforms" ...
                loaded library "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll"
                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platformthemes" ...
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platformthemes" ...
                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforminputcontexts" ...
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platforminputcontexts" ...
                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/styles" ...
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/styles" ...
                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines" ...
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
                "MetaData": {
                "Keys": [
                "svg",
                "svgz",
                "svg.gz"
                ]
                },
                "className": "QSvgIconPlugin",
                "debug": false,
                "version": 328960
                }

                "The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
                not a plugin
                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicond.dll"
                Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicond.dll, metadata=
                {
                "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
                "MetaData": {
                "Keys": [
                "svg",
                "svgz",
                "svg.gz"
                ]
                },
                "className": "QSvgIconPlugin",
                "debug": true,
                "version": 328960
                }

                Got keys from plugin meta data ("svg", "svgz", "svg.gz")
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/iconengines" ...
                "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug"
                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/accessiblebridge" ...
                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/accessiblebridge" ...

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 29 Sept 2015, 22:10 last edited by
                  #8

                  Ok, I missed you wrote MinGW in your title. IIRC MySQL is built with Visual Studio. So you need to build the libraries with MinGW.

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

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andrew87
                    wrote on 29 Sept 2015, 22:15 last edited by
                    #9

                    I'm sorry, I did not understand what you mean.
                    What should I build exactly? Can I find some guide somewhere?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 29 Sept 2015, 22:58 last edited by
                      #10

                      You are currently using a MSVC build of MySQL which is not compatible with your MinGW 32 Qt installation. IIRC your can download and build the MySQL connector library. You can find some instructions here

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

                      1 Reply Last reply
                      0
                      • A andrew87
                        29 Sept 2015, 21:13

                        Hello everybody!

                        Sorry for my English, I don't speak or write often it.
                        This is the third day that I'm struggling whit this plugin, before this post I have looked everywhere in this forum (and others), without find the solution.

                        The code:

                        db = new QSqlDatabase();
                        qDebug() << "drivers:" db->drivers();
                        db->setHostName("localhost");
                        qDebug() << db->addDatabase("QMYSQL3");
                        qDebug() << "Valid? "<< db->isValid();    // Returns true if connection exists
                        qDebug() << db->lastError();
                        

                        And the output:

                        drivers: ("QMYSQL", "QMYSQL3")
                        QSqlDatabase(driver="QMYSQL3", database="", host="", port=-1, user="", open=false)
                        Valid? false
                        QSqlError("", "Driver not loaded", "Driver not loaded")

                        I use it on Ubuntu with succes, but now, in windows it seems there's no way to make it work.
                        I tried the prebuilt plugin, and also the compiled one from source code after watching a lot of tutorial, guide ecc.

                        I already:

                        • Added to the environment path (both in qt and in windows) of minwg "bin", mysql "lib" qt "bin" folder.
                        • Copied libmysql.dll and mysqlclient.lib (from mysql directory) to each directory possible
                        • Included mysql library directories to the project with:
                          QMAKE_LIBDIR += "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
                          LIBS += libmysql
                        • tried with visual studio compiler version
                        • installed and tried 4 different version of mysql (and XAMPP)
                        • generated: libmysql.def and libmysql.a with reimp and dlltool command
                        • the pointer to QSqlDatabase is allocated after QApplication has initialized

                        As you can see, the qsqlmysql.dll driver is recognized but the driver isn't loaded, why?
                        What should I have been wrong?

                        A Offline
                        A Offline
                        andrew87
                        wrote on 30 Sept 2015, 13:11 last edited by andrew87
                        #11

                        Unfortunately it appear difficult to find the source code that can be compiled with the latest version of cmake and mingw, I tried and had several building error.

                        I found this link: Compiling mysql connector C++ with mingw, compiling errors in wich there are the same errors.

                        I misunderstood or it seems that anyone that want to use the qt plugin for mysql (with mingw) have to use a 4 or 5 years old source code? Maybe I should switch to visual studio compiler?

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 30 Sept 2015, 21:41 last edited by
                          #12

                          That I can't comment on. You should ask the MySQL people about that matter.

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

                          1 Reply Last reply
                          0

                          1/12

                          29 Sept 2015, 21:13

                          • Login

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