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

QMYSQL driver build problem



  • Re: Trouble building the QMYSQL Plugin on Unix (Mint 19.2)

    I have the same problem with MacOs X (Catalina) :

    sqldrivers % /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_PREFIX=/usr/local

    Running configuration tests...
    Done running configuration tests.

    Configure summary:

    Qt Sql Drivers:
    DB2 (IBM) .............................. no
    InterBase .............................. no
    MySql .................................. no
    OCI (Oracle) ........................... no
    ODBC ................................... no
    PostgreSQL ............................. no
    SQLite2 ................................ no
    SQLite ................................. yes
    Using system provided SQLite ......... no
    TDS (Sybase) ........................... no

    Tried /usr/local/mysql
    but same

    log file :

    (only mysql part)
    loaded result for library config.sqldrivers.libraries.mysql
    Trying source 0 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    => source produced no result.
    Trying source 1 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    => source produced no result.
    Trying source 2 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    => source produced no result.
    Trying source 3 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    => source produced no result.
    Trying source 4 (type inline) of library mysql ...
    mysql.h not found in [/usr/local/include] and global paths.
    => source produced no result.
    Trying source 5 (type inline) of library mysql ...
    => source failed condition 'config.win32'.
    Trying source 6 (type inline) of library mysql ...
    mysql.h not found in [/usr/local/include] and global paths.
    => source produced no result.
    test config.sqldrivers.libraries.mysql FAILED

    Thanks



  • Ops sorry solved removing config.cache

    sorry



  • Ehm.....
    but still QSqlDatabase: QMYSQL driver not loaded

    mysql in /usr/local

    using otool
    otool -L libqsqlmysql.dylib

    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 800.6.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

    thanks


  • Lifetime Qt Champion

    Start your application with the QT_DEBUG_PLUGINS environment variable set to 1.

    That will give you more information about what is going on.



  • @lorenko https://forum.qt.io/topic/113712/qmysql-driver-not-loaded see my topic and all probelm in Make file open it with notepad or IDE C++ config the link INCLUDEPATH or LIBS I have lost 1 week this fuck problem

    you can using
    qmake INCLUDEPATH+="C:\PROGRA~2\MySQL\MYSQLS~1.5\include" LIBS+="C:\PROGRA~2\MySQL\MYSQLS~1.5\lib\libmysql.lib"mysql.pro

    or qmake -- MYSQL_INCDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\include" MYSQL_LIBDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\lib"

    but the linked you can see in Make-file is wrong because you using qmake more than 1 and Makefile buid linked wrong.


  • Lifetime Qt Champion

    @nguyendinh said in QMYSQL driver build problem:

    because you using qmake more than 1 and Makefile buid linked wrong

    Instead of editing makefiles make sure you start from a clean state: do out of source builds and delete content of the build directory before calling qmake again.



  • Thanks, but no way

    this my config log

    Command line: MYSQL_INCDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/include MYSQL_LIBDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/lib
    Global lib dirs: [] [/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib]
    Global inc dirs: [/usr/local/opt/openssl/include] [/Library/Developer/CommandLineTools/usr/include/c++/v1 /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include /Library/Developer/CommandLineTools/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include]
    
    loaded result for library config.sqldrivers.libraries.mysql
    Trying source 0 (type mysqlConfig) of library mysql ...
    mysql_config not found.
      => source produced no result.
    Trying source 1 (type mysqlConfig) of library mysql ...
    mysql_config not found.
      => source produced no result.
    Trying source 2 (type mysqlConfig) of library mysql ...
    mysql_config not found.
      => source produced no result.
    Trying source 3 (type mysqlConfig) of library mysql ...
    mysql_config not found.
      => source produced no result.
    Trying source 4 (type inline) of library mysql ...
    + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" 'INCLUDEPATH += /usr/local/opt/openssl/include' 'QMAKE_USE += mysql' 'QMAKE_LIBS_MYSQL = -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r' 'QMAKE_INCDIR_MYSQL = /usr/local/mysql-8.0.19-macos10.15-x86_64/include' /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
    + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && MAKEFLAGS= make clean && MAKEFLAGS= make
    > rm -f main.o
    > rm -f *~ core *.core
    > /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -w -fPIC  -I. -I/usr/local/opt/openssl/include -I/usr/local/mysql-8.0.19-macos10.15-x86_64/include -I/Users/lorenko/Qt5.14.2/5.14.2/clang_64/mkspecs/macx-clang -o main.o main.cpp
    > /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wl,-rpath,@executable_path/../Frameworks -o mysql main.o   -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r   
    > ld: library not found for -lmysqlclient_r
    > clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    and qmake command

    /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_INCDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/include" MYSQL_LIBDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/lib"
    

    same results

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

  • Qt Champions 2017

    You have the plugin already.

    QSqlDatabase: available drivers: QSQLITE QMYSQL ...

    Have you debugged why it doesn't load, like @SGaist suggested?



  • @SGaist said in QMYSQL driver build problem:

    Start your application with the QT_DEBUG_PLUGINS environment variable set to 1.

    Ohh, sorry you're right and my apologies to @SGaist

    QFactoryLoader::QFactoryLoader() checking directory path "/Users/lorenko/progetti/build-BoraApp-Desktop_Qt_5_14_2_clang_64bit-Debug/BoraApp.app/Contents/MacOS/sqldrivers" ...
    Cannot load library /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib
      Referenced from: /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
      Reason: image not found)
    QLibraryPrivate::loadPlugin failed on "/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib\n  Referenced from: /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    

    The problem was solved copiyng mysql libraries to /usr/local/lib

    thank you very much and sorry again


  • Lifetime Qt Champion

    One thing you can do is use install_name_tool and update the MySQL library path to use the full path.



  • Yes, best way, thx



  • This post is deleted!


  • @worldpiece said in QMYSQL driver build problem:

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

    Hey, I did this successfully, like I think that you also did, as you have the QMYSQL driver.

    I had to copy libmysql, from the MySQL Server dir to my exe /debug/release folder together with the dependency libs from openssl,
    libssl-1_1-x64
    libcrypto-1_1-x64

    I also had to copy the qmysql drivers to a folder named sqldrivers my exe folder..

    But a guy who just had this problem had to make fewer changes, all he needed to do was add the openssl libs to the exe/build folder, so maybe try that first.


Log in to reply