Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTDriver not Load
Forum Updated to NodeBB v4.3 + New Features

QTDriver not Load

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
33 Posts 6 Posters 10.2k Views 2 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.
  • kmyukieK Offline
    kmyukieK Offline
    kmyukie
    wrote on last edited by kmyukie
    #24

    Hello, I have the same problem as @lucaynnofrota. I think I might be using the wrong commands to compile the MySQL plugin, although I have tried to follow the documentation. I'm on a Mac.
    I've inputted in Terminal:

    cd /Volumes/Potato/apps/5.11.2/Src/qtbase/src/plugins/sqldrivers
    qmake -- MYSQL_PREFIX=/usr/local/mysql
    make sub-mysql
    

    In which "apps" is the Qt folder I've accidentally renamed.
    But whenever I try to execute this:

    #include <iostream>
    #include <QtSql>
    #include <QtCore>
    #include <QString>
    #include <QCoreApplication>
    using namespace std;
    
    int main(int argc,char *argv[])
    {
           QCoreApplication a(argc,argv);
    
           QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
           bool ok = db.open();
           if(ok) cout << "OK!\n";
           qDebug() << db.lastError();
    }
    

    I get :

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    QSqlError("", "Driver not loaded", "Driver not loaded")
    

    My .pro file is:

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG += qt
    QT += sql gui
    SOURCES += \
            main.cpp
    

    What am I doing wrong?
    Thanks!

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

      Hi,

      Add the QT_DEBUG_PLUGINS environment variable in the Run part of the Project panel. You'll have more information about why the plugins doesn't load. A wild guess would be that the application can't find the MySQL dlls at run time.

      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
      1
      • kmyukieK Offline
        kmyukieK Offline
        kmyukie
        wrote on last edited by
        #26

        Thanks for replying!
        I've tried to set QT_DEBUG_PLUGINS to 1, and the output is:

        cd /; /Volumes/Potato/apps/Qt\ Creator.app/Contents/MacOS/../Resources/qtcreator_process_stub run /var/folders/sv/76q4jsns75g48tkx3b4g__3c0000gn/T/QtCreator.kFAuXu/stub-socket Press\ \<RETURN\>\ to\ close\ this\ window... /Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release /var/folders/sv/76q4jsns75g48tkx3b4g__3c0000gn/T/QtCreator.KiilXk 23590 /Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release/testsqlite
        QFactoryLoader::QFactoryLoader() checking directory path "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers" ...
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QSQLITE"
                ]
            },
            "className": "QSQLiteDriverPlugin",
            "debug": false,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QSQLITE")
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QSQLITE"
                ]
            },
            "className": "QSQLiteDriverPlugin",
            "debug": true,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QSQLITE")
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QMYSQL3",
                    "QMYSQL"
                ]
            },
            "className": "QMYSQLDriverPlugin",
            "debug": false,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QMYSQL3",
                    "QMYSQL"
                ]
            },
            "className": "QMYSQLDriverPlugin",
            "debug": true,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QPSQL7",
                    "QPSQL"
                ]
            },
            "className": "QPSQLDriverPlugin",
            "debug": false,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QPSQL7", "QPSQL")
        QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib"
        Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QPSQL7",
                    "QPSQL"
                ]
            },
            "className": "QPSQLDriverPlugin",
            "debug": true,
            "version": 330498
        }
        
        
        Got keys from plugin meta data ("QPSQL7", "QPSQL")
        QFactoryLoader::QFactoryLoader() checking directory path "/Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release/sqldrivers" ...
        Cannot load library /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
          Referenced from: /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
          Reason: image not found)
        QLibraryPrivate::loadPlugin failed on "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
        QSqlDatabase: QMYSQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
        QSqlError("", "Driver not loaded", "Driver not loaded")
        QSqlQuery::prepare: database not open
        QSqlQuery::prepare: database not open
        QSqlQuery::prepare: database not open
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #27

          I didn't realise that you are working on macOS. This thread is for Windows.

          As for your issue, it has already been answered many times already on this forum. Please search it.

          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
          • kmyukieK kmyukie

            Hello, I have the same problem as @lucaynnofrota. I think I might be using the wrong commands to compile the MySQL plugin, although I have tried to follow the documentation. I'm on a Mac.
            I've inputted in Terminal:

            cd /Volumes/Potato/apps/5.11.2/Src/qtbase/src/plugins/sqldrivers
            qmake -- MYSQL_PREFIX=/usr/local/mysql
            make sub-mysql
            

            In which "apps" is the Qt folder I've accidentally renamed.
            But whenever I try to execute this:

            #include <iostream>
            #include <QtSql>
            #include <QtCore>
            #include <QString>
            #include <QCoreApplication>
            using namespace std;
            
            int main(int argc,char *argv[])
            {
                   QCoreApplication a(argc,argv);
            
                   QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
                   bool ok = db.open();
                   if(ok) cout << "OK!\n";
                   qDebug() << db.lastError();
            }
            

            I get :

            QSqlDatabase: QMYSQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
            QSqlError("", "Driver not loaded", "Driver not loaded")
            

            My .pro file is:

            TEMPLATE = app
            CONFIG += console c++11
            CONFIG -= app_bundle
            CONFIG += qt
            QT += sql gui
            SOURCES += \
                    main.cpp
            

            What am I doing wrong?
            Thanks!

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

            @kmyukie Didn't you forgot "make install"?

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

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @lucaynnofrota said in QTDriver not Load:

              D:/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri

              Does this file exist?

              A Offline
              A Offline
              ankurboruah
              wrote on last edited by
              #29

              @jsulm I had the same issue as @lucaynnofrota where the qtsqldrivers-config.pri file was not found. Any idea where I can find the file?

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

                @ankurboruah This file is created when you configure Qt.

                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
                0
                • SGaistS SGaist

                  @ankurboruah This file is created when you configure Qt.

                  A Offline
                  A Offline
                  ankurboruah
                  wrote on last edited by
                  #31

                  @SGaist Thanks for your reply. I came to the same conclusion as well. Going through with configuring Qt. Hopefully no errors pop up during that.

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

                    Which version of Qt are you trying to build the driver for ?

                    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
                    • L Offline
                      L Offline
                      lucaynnofrota
                      wrote on last edited by
                      #33

                      The problem with MySQL I could not solve.
                      I tried using Postgres and I had no problem. Shortly afterwards I realized that I was making a Mistake, the latest versions of MySQL are for 64bit and the version I was using from 32bit qt

                      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