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

QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7



  • hi,I have the same problem with MacOs X (Mojave) :
    I'm trying to sift through the many and aging recommendations of how to successfully build a mysql driver for Qt.
    emm.."然并卵" !_!

    step 1 :

    /Users/ing/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_PREFIX=/usr/local/mysql
    

    results:

    Running configuration tests...
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql Drivers:
    DB2 (IBM) .............................. no
    InterBase .............................. no
    MySql .................................. yes
    OCI (Oracle) ........................... no
    ODBC ................................... no
    PostgreSQL ............................. no
    SQLite2 ................................ no
    SQLite ................................. yes
    Using system provided SQLite ......... no
    TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/Users/ing/Qt5.14.2/5.14.2/clang_64'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    step 2 :

    **otool -L libqsqlmysql.dylib**
    

    results:

    libqsqlmysql.dylib:
    libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.14.0, current version 5.14.2)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.14.0, current version 5.14.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)
    @rpath/libmysqlclient.21.dylib (compatibility version 21.0.0, current version 21.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
    

    step 3:

    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.21.dylib @rpath/libmysqlclient.21.dylib /Users/ing/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
    
    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.21.dylib /usr/local/mysql-8.0.20-macos10.15-x86_64/lib/libmysqlclient.21.dylib
     /Users/ing/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
    

    Emm...but still :

    10:24:16: Starting /Users/ing/Documents/learn/qt/build-QtMysql-Desktop_Qt_5_14_2_clang_64bit-Debug/QtMysql.app/Contents/MacOS/QtMysql ...
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    10:24:20: /Users/ing/Documents/learn/qt/build-QtMysql-Desktop_Qt_5_14_2_clang_64bit-Debug/QtMysql.app/Contents/MacOS/QtMysql exited with code 0
    

    Related configuration:

    #bash_profile:
    #Setting PATH for qmake
    export QTDIR=/Users/ing/Qt5.14.2/5.14.2/clang_64
    export QT_DEBUG_PLUGINS=1
    export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    export PATH=$QTDIR/bin:$PATH
    export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib
    

    Have spent a day on this,help!! ths very much!



  • @worldpiece said in QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7:

    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.21.dylib @rpath/libmysqlclient.21.dylib /Users/ing/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

    Found the problem -- step3 :
    change

    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.21.dylib @rpath/libmysqlclient.21.dylib /Users/ing/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
    
    

    to

    install_name_tool -change @rpath/libmysqlclient.21.dylib /usr/local/mysql/lib/libmysqlclient.21.dylib   /Users/ing/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
    

    solved!


Log in to reply