Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMYSQL driver not loaded..



  • Re: QMYSQL driver not loaded on mac

    Hi,
    I have the same problem.. read, try, re-try.. but don't work..

    Mac os X 10.13.6 / MySql 5.7 / Qt 5.11.2

    i've read many post, try several times with "otool" and "install_name_tool" but i can't connect with mysql database..

    0_1536655393054_Schermata 2018-09-11 alle 10.42.03.png

    this is the result..

    0_1536655455828_Schermata 2018-09-11 alle 10.43.39.png 0_1536655465731_Schermata 2018-09-11 alle 10.43.53.png

    Anyone can help me please?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Start your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see exactly what is happening.



  • @SGaist said in QMYSQL driver not loaded..:

    QT_DEBUG_PLUGINS environment variable set to 1

    ok, i post the "DRIVER SQL" part of console msg:

    QFactoryLoader::QFactoryLoader() checking directory path "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers" ...
    QFactoryLoader::QFactoryLoader() looking at "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#"
    QMachOParser: '/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#' is not a valid Mach-O binary (file too small)
    "'/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#' is not a valid Mach-O binary (file too small)" 
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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/matteo/Desktop/C++/QT/EasyGest/build-EasyGest-Desktop_Qt_5_11_2_clang_64bit18-Debug/EasyGest.app/Contents/MacOS/sqldrivers" ...
    Cannot load library /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
      Referenced from: /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
      Reason: image not found)
    QLibraryPrivate::loadPlugin failed on "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/matteo/Qt/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
    

    i don't understand.. i think the problem is point to "0tz#"" ??? directory in "sqldrivers"..
    what i have to do to fix it??

    Thanks in advance.


  • Lifetime Qt Champion

    Where is your libmysqlclient.XX.dylib file located on your machine ?



  • @SGaist said in QMYSQL driver not loaded..:

    libmysqlclient.XX.dylib

    i found "libmysqlclient.20.dylib" in:

    /opt/local/lib/mysql57/mysql/

    folder


  • Lifetime Qt Champion

    Then fix that path using install_name_tool



  • i can't fix it..

    i try with

    0_1536758727291_Schermata 2018-09-12 alle 15.23.08.png

    but no solutions..

    where is the problem??


  • Lifetime Qt Champion

    What are you trying to modify libmysqlclient.20.dylib ?

    It's the plugin that you should update.

    Note that the entry ending with 0tz# doesn't make any sense.



  • how can i update the plugin???

    i havo to use install_name_tool?

    sorry but i'm beginner with Qt


  • Lifetime Qt Champion

    Yes, that's the tool.

    It has nothing to do with Qt. It's macOS library management. If you search the forum a bit, you can find many threads about the same topic.



  • @TheCipo76 said in QMYSQL driver not loaded..:

    /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#

    i don't understand what i have to do with install_name_tool

    how can i update plugin??

    i've tried some times but i can't find the right way..

    install_name_tool -change /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#  /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers /opt/local/lib/mysql57/mysql/libqsqlmysql.dylib
    

    give me this error..

    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open file: /opt/local/lib/mysql57/mysql/libqsqlmysql.dylib (No such file or directory)

    can you help me please?


  • Lifetime Qt Champion

    That error is pretty clear: there's no libqsqlmysql.dylib in /opt/local/lib/mysql57/mysql/ which is normal since that's a Qt plugin and it has nothing to do in the MySQL install folder.

    Did you even tried to read the documentation of install_name_tool ?

    install_name_tool -change old new input :

    • old is the old path you want to change
    • new is the path which you want to use in place of old
    • input is either a library or an application where you want to do the modification.

    Note that both old and new are path to libraries.



  • hi, yes i read man page before try .. but i can't solve..

    i've tried with:

    install_name_tool -change /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#  /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
    

    but the path is the same..

    this is the console message:

    QFactoryLoader::QFactoryLoader() checking directory path "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers" ...
    QFactoryLoader::QFactoryLoader() looking at "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#"
    QMachOParser: '/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#' is not a valid Mach-O binary (file too small)
    "'/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/0tz#' is not a valid Mach-O binary (file too small)" 
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
    Found metadata in lib /Users/matteo/Qt/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 "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib"
    Found metadata in lib /Users/matteo/Qt/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/matteo/Desktop/C++/QT/EasyGest/build-EasyGest-Desktop_Qt_5_11_2_clang_64bit18-Debug/EasyGest.app/Contents/MacOS/sqldrivers" ...
    Cannot load library /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
      Referenced from: /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
      Reason: image not found)
    QLibraryPrivate::loadPlugin failed on "/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/matteo/Qt/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
    

    where is the problem this time??

    why the only plugin with problems is the one i need and the other's seem to be ok??


  • Lifetime Qt Champion

    Again that's wrong. This is a list of libraries and where you can find them, you are trying to change that for just a folder so it won't work.

    Re-run otool -Lon the plugin to see the exact list.

    As for MySQL:

    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.20.dylib /opt/local/lib/mysql57/mysql/libmysqlclient.20.dylib /Users/matteo/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib



  • Ok, finally work!

    Thank you for patience and constancy you've used with me.


  • Lifetime Qt Champion

    @TheCipo76 said in QMYSQL driver not loaded..:

    Ok, finally work!

    Can you please make the thread as solved then? Thx.



  • i've installed Qt in another mac and i've the same problem

    i run otool -L and this is reply:

    libqsqlmysql.dylib:
    	libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    	@rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.11.0, current version 5.11.2)
    	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.11.0, current version 5.11.2)
    	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    	/usr/local/mysql/lib/libmysqlclient.21.dylib (compatibility version 20.0.0, current version 20.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
    

    i've checked the path and it's OK (fixed with install_name_tool -change...)

    when i run my App (with QT_DEBUG_PLUGINS set to 1)
    i've this debug result:

    QFactoryLoader::QFactoryLoader() checking directory path "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers" ...
    QFactoryLoader::QFactoryLoader() looking at "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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 "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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 "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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 "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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 "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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 "/Users/matteomissora/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib"
    Found metadata in lib /Users/matteomissora/Qt/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/matteomissora/build-EasyGest-Desktop_Qt_5_11_2_clang_64bit18-Debug/EasyGest.app/Contents/MacOS/sqldrivers" ...
    QSqlDatabase: MYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    

    why don't work?


  • Lifetime Qt Champion

    Because you have a type: it's QMYSQL you only wrote MYSQL.



  • i missed..
    i didn' see it..
    Thank you..


Log in to reply