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

QTDriver not Load



  • Hi guys.

    I'm in trouble to load MySQL drivers on QT.

    I need to add MySQL in my project to make Server/Client connection with MySQL.

    I have the same problem this guy :https://forum.qt.io/topic/92626/cant-connect-to-mysql-database-qmysql-driver-not-loaded
    I'm trying to replicate steps, But i'm stuck on qmakefile step.

    I'm having trouble to execute these code lines

    This code is on .bat file.

    My cmd input{
    D:\Qt\5.11.2\Src\qtbase\src\plugins
    qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" MYSQL_LIBDIR="C:\Program
    MySQL\MySQL Server 8.0\lib"

    mingw32-make sub-mysql
    }
    My cmd output{

    C:\Users\lucya\Desktop>D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers
    'D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\lucya\Desktop>qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
    Usage: qmake [mode] [options] [files]

    QMake has two modes, one mode for generating project files based on
    some heuristics, and the other for generating makefiles. Normally you
    shouldn't need to specify a mode, as makefile generation is the default
    mode for qmake, but you may use this to test qmake on an existing project

    Mode:
    -project Put qmake into project file generation mode
    In this mode qmake interprets files as files to
    be built,
    defaults to *; *; *; *.ts; *.xlf; *.qrc
    Note: The created .pro file probably will
    need to be edited. For example add the QT variable to
    specify what modules are required.
    -makefile Put qmake into makefile generation mode (default)
    In this mode qmake interprets files as project files to
    be processed, if skipped qmake will try to find a project
    file in your current working directory

    Warnings Options:
    -Wnone Turn off all warnings; specific ones may be re-enabled by
    later -W options
    -Wall Turn on all warnings
    -Wparser Turn on parser warnings
    -Wlogic Turn on logic warnings (on by default)
    -Wdeprecated Turn on deprecation warnings (on by default)

    Options:

    You can place any variable assignment in options and it will be *
    processed as if it was in [files]. These assignments will be *
    processed before [files] by default. *
    -o file Write output to file
    -d Increase debug level
    -t templ Overrides TEMPLATE as templ
    -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value
    -help This help
    -v Version information
    -early All subsequent variable assignments will be
    parsed right before default_pre.prf
    -before All subsequent variable assignments will be
    parsed right before [files] (the default)
    -after All subsequent variable assignments will be
    parsed after [files]
    -late All subsequent variable assignments will be
    parsed right after default_post.prf
    -norecursive Don't do a recursive search
    -recursive Do a recursive search
    -set <prop> <value> Set persistent property
    -unset <prop> Unset persistent property
    -query <prop> Query persistent property. Show all if <prop> is empty.
    -qtconf file Use file instead of looking for qt.conf
    -cache file Use file as cache [makefile mode only]
    -spec spec Use spec as QMAKESPEC [makefile mode only]
    -nocache Don't use a cache file [makefile mode only]
    -nodepend Don't generate dependencies [makefile mode only]
    -nomoc Don't generate moc targets [makefile mode only]
    -nopwd Don't look for files in pwd [project mode only]
    C:\Users\lucya\Desktop>mingw32-make sub-mysql
    mingw32-make: *** No rule to make target 'sub-mysql'. Stop.
    }

    What i'm doing wrong?

    I'm using qt 5.11.2 MingW 32Bit. MySQL 8.0

    Thanks for attention.


  • Lifetime Qt Champion

    Hi,

    Didn't you forget the cd command to move to the right folder before calling qmake ?



  • I didn't forget it. I have removed in the edition

    My cmd input{
    cd D:\Qt\5.11.2\Src\qtbase\src\plugins
    qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" MYSQL_LIBDIR="C:\Program
    MySQL\MySQL Server 8.0\lib"

    mingw32-make sub-mysql
    }


  • Lifetime Qt Champion

    @lucaynnofrota This error means you DID forget cd:
    "'D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers' is not recognized as an internal or external command,
    operable program or batch file."

    You already asked same question here: https://forum.qt.io/topic/92626/cant-connect-to-mysql-database-qmysql-driver-not-loaded



  • Now i'm stuck with this error:

    Input:
    cd %QTDIR%\qtbase\src\plugins\sqldrivers
    set mysql=C:\Program Files\MySQL\MySQL Server 8.0
    qmake -- MYSQL_INCDIR=%mysql%\include "MYSQL_LIBDIR=%mysql%\lib\opt"
    Output:
    Cannot read D:/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
    Project ERROR: Library 'mysql' is not defined.

    Someone knows what am i suppose to do?


  • Lifetime Qt Champion

    @lucaynnofrota said in QTDriver not Load:

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

    Does this file exist?



  • @jsulm
    Thanks for replay. I've already solved this problem. But i'm haven't solved mysql problem.

    cmd:

    input:

    C:\Users\lucya\Desktop\Qt Driver>set mysql=C:\Program Files\MySQL\MySQL Server 8.0
    
    C:\Users\lucya\Desktop\Qt Driver>cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    
    C:\Users\lucya\Desktop\Qt Driver>qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\\lib\\libmysql.lib" -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    

    output:

    Info: creating stash file C:\Users\lucya\Desktop\Qt Driver\.qmake.stash
    
    Running configuration tests...
    Checking for DB2 (IBM)... no
    Checking for InterBase... no
    Checking for MySQL... no
    Checking for OCI (Oracle)... no
    Checking for ODBC... yes
    Checking for PostgreSQL... no
    Checking for SQLite (version 2)... no
    Checking for TDS (Sybase)... no
    Done running configuration tests.
    

    Configure summary:

    Qt Sql:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... yes
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'mingw32-make'.
    Once everything is built, Qt is installed.
    You should NOT run 'mingw32-make install'.
    Note that this build cannot be deployed to other machines or devices.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    ####################################### config.log ###########################

    Command line: 
    looking for library db2
    Trying source 0 (type inline) of library db2 ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\db2" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -ldb2cli" "C:/Users/lucya/Desktop/Qt Driver/config.tests/db2"
    > Info: creating stash file C:\Users\lucya\Desktop\Qt Driver\config.tests\.qmake.stash
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\db2" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:20: fatal error: sqlcli.h: No such file or directory
    > compilation terminated.
    > Makefile:413: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 1 (type inline) of library db2 ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.db2 FAILED
    looking for library ibase
    Trying source 0 (type inline) of library ibase ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\ibase" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lgds32_ms" "C:/Users/lucya/Desktop/Qt Driver/config.tests/ibase"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\ibase" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:19: fatal error: ibase.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 1 (type inline) of library ibase ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.ibase FAILED
    looking for library 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 ...
      => source failed condition '!config.win32'.
    Trying source 5 (type inline) of library mysql ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\mysql" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -llibmysql" "C:/Users/lucya/Desktop/Qt Driver/config.tests/mysql"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\mysql" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:5:19: fatal error: mysql.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 6 (type inline) of library mysql ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.mysql FAILED
    looking for library oci
    Trying source 0 (type inline) of library oci ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\oci" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -loci" "C:/Users/lucya/Desktop/Qt Driver/config.tests/oci"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\oci" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:17: fatal error: oci.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 1 (type inline) of library oci ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.oci FAILED
    looking for library odbc
    Trying source 0 (type inline) of library odbc ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\odbc" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lodbc32" "C:/Users/lucya/Desktop/Qt Driver/config.tests/odbc"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\odbc" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > g++ -Wl,-s -Wl,-subsystem,console -mthreads -o odbc.exe main.o  -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.6.11-win32\lib -LC:\Utils\postgresql\pgsql\lib -lodbc32 
     => source accepted.
    test config.sqldrivers.libraries.odbc succeeded
    looking for library psql
    Trying source 0 (type pkgConfig) of library psql ...
    pkg-config use disabled globally.
      => source produced no result.
    Trying source 1 (type psqlConfig) of library psql ...
    pg_config not found.
      => source produced no result.
    Trying source 2 (type psqlEnv) of library psql ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\psql" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -llibpq -lws2_32 -ladvapi32" "C:/Users/lucya/Desktop/Qt Driver/config.tests/psql"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\psql" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 3 (type psqlEnv) of library psql ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.psql FAILED
    looking for library sqlite2
    Trying source 0 (type inline) of library sqlite2 ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\sqlite2" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lsqlite" "C:/Users/lucya/Desktop/Qt Driver/config.tests/sqlite2"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\sqlite2" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:20: fatal error: sqlite.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    test config.sqldrivers.libraries.sqlite2 FAILED
    looking for library tds
    Trying source 0 (type sybaseEnv) of library tds ...
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\tds" && D:\Qt\5.11.2\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lNTWDBLIB" "C:/Users/lucya/Desktop/Qt Driver/config.tests/tds"
    + cd /d "C:\Users\lucya\Desktop\Qt Driver\config.tests\tds" && set MAKEFLAGS=& mingw32-make
    > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -ID:\Qt\5.11.2\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    > main.cpp:2:22: fatal error: sybfront.h: No such file or directory
    > compilation terminated.
    > Makefile:415: recipe for target 'main.o' failed
    > mingw32-make: *** [main.o] Error 1
     => source failed verification.
    Trying source 1 (type sybaseEnv) of library tds ...
      => source failed condition '!config.win32'.
    test config.sqldrivers.libraries.tds FAILED
    
    
    ####################################### config.cache ###########################
    
    cache.platform = win32-g++
    cache.xplatform = win32-g++
    cache.db2._KEYS_ = result msgs
    cache.db2.result = false
    cache.db2.msgs = "Trying source 0 (type inline) of library db2 ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\db2\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -ldb2cli\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/db2\"" "> Info: creating stash file C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\.qmake.stash" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\db2\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:20: fatal error: sqlcli.h: No such file or directory" "> compilation terminated." "> Makefile:413: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library db2 ..." "  => source failed condition \'!config.win32\'."
    cache.ibase._KEYS_ = result msgs
    cache.ibase.result = false
    cache.ibase.msgs = "Trying source 0 (type inline) of library ibase ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\ibase\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lgds32_ms\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/ibase\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\ibase\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:19: fatal error: ibase.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library ibase ..." "  => source failed condition \'!config.win32\'."
    cache.mysql._KEYS_ = result msgs
    cache.mysql.result = false
    cache.mysql.msgs = "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 ..." "  => source failed condition \'!config.win32\'." "Trying source 5 (type inline) of library mysql ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\mysql\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -llibmysql\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/mysql\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\mysql\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:5:19: fatal error: mysql.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 6 (type inline) of library mysql ..." "  => source failed condition \'!config.win32\'."
    cache.oci._KEYS_ = result msgs
    cache.oci.result = false
    cache.oci.msgs = "Trying source 0 (type inline) of library oci ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\oci\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -loci\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/oci\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\oci\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:17: fatal error: oci.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library oci ..." "  => source failed condition \'!config.win32\'."
    cache.odbc._KEYS_ = result msgs source sources.0.libs sources.0.includedir sources.0.cflags sources.0.version sources.0.export
    cache.odbc.result = true
    cache.odbc.msgs = "Trying source 0 (type inline) of library odbc ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\odbc\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lodbc32\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/odbc\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\odbc\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> g++ -Wl,-s -Wl,-subsystem,console -mthreads -o odbc.exe main.o  -LC:\\openssl\\lib -LC:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib -LC:\\Utils\\postgresql\\pgsql\\lib -lodbc32 " " => source accepted."
    cache.odbc.source = 0
    cache.odbc.sources.0.libs = -lodbc32
    cache.odbc.sources.0.includedir = 
    cache.odbc.sources.0.cflags = 
    cache.odbc.sources.0.version = 
    cache.odbc.sources.0.export = 
    cache.psql._KEYS_ = result msgs
    cache.psql.result = false
    cache.psql.msgs = "Trying source 0 (type pkgConfig) of library psql ..." "pkg-config use disabled globally." "  => source produced no result." "Trying source 1 (type psqlConfig) of library psql ..." "pg_config not found." "  => source produced no result." "Trying source 2 (type psqlEnv) of library psql ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\psql\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -llibpq -lws2_32 -ladvapi32\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/psql\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\psql\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 3 (type psqlEnv) of library psql ..." "  => source failed condition \'!config.win32\'."
    cache.sqlite2._KEYS_ = result msgs
    cache.sqlite2.result = false
    cache.sqlite2.msgs = "Trying source 0 (type inline) of library sqlite2 ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\sqlite2\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lsqlite\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/sqlite2\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\sqlite2\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:20: fatal error: sqlite.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification."
    cache.tds._KEYS_ = result msgs
    cache.tds.result = false
    cache.tds.msgs = "Trying source 0 (type sybaseEnv) of library tds ..." "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\tds\" && D:\\Qt\\5.11.2\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lNTWDBLIB\" \"C:/Users/lucya/Desktop/Qt Driver/config.tests/tds\"" "+ cd /d \"C:\\Users\\lucya\\Desktop\\Qt Driver\\config.tests\\tds\" && set MAKEFLAGS=& mingw32-make" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -ID:\\Qt\\5.11.2\\mingw53_32\\mkspecs\\win32-g++  -o main.o main.cpp" "> main.cpp:2:22: fatal error: sybfront.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type sybaseEnv) of library tds ..." "  => source failed condition \'!config.win32\'."
    

    ####################################### qtsqldrivers-config.pri ###########################

    QT.sqldrivers.enabled_features = 
    QT.sqldrivers.disabled_features = 
    QT.sqldrivers.QT_CONFIG = 
    QT.sqldrivers.exports = 
    QT.sqldrivers_private.enabled_features = sql-odbc sql-sqlite
    QT.sqldrivers_private.disabled_features = sql-db2 sql-ibase sql-mysql sql-oci sql-psql sql-sqlite2 sql-tds system-sqlite
    QT.sqldrivers_private.libraries = odbc
    QMAKE_LIBS_ODBC = -lodbc32
    

  • Lifetime Qt Champion

    @lucaynnofrota said in QTDriver not Load:

    C:\Utils\postgresql\pgsql\include

    It looks like you're trying to build all SQL drivers. Maybe you can only build MySQL? (never tried that)



  • @jsulm
    How do I do that?
    I'm only trying to replicate the step on the documentation.


  • Lifetime Qt Champion

    @lucaynnofrota What if you do

    cd %QTDIR%\qtbase\src\plugins\sqldrivers\mysql
    

    ?



  • @jsulm

    Thanks for replay

    I don't have qtbase on %QTDIR% folder.

    qtbase is on my version folders %QTDIR%\5.11.2\Src\qtbase or %QTDIR%5.12.0\Src\qtbase

    Is to suppose to have qtbase on qt directory?

    In relation to what you said it is exactly what i'm doing!
    cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\


  • Lifetime Qt Champion

    @lucaynnofrota What I mean is: do

    cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\mysql
    

    instead of

    cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    


  • I have tried this but it doesn't work. It's the same output.


  • Lifetime Qt Champion



  • @jsulm

    Yeah.
    I have added to the PATH C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin
    And then i executed this .bat file:

    set mysql=C:\Program Files\MySQL
    cd D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=%mysql%\\MySQL Server 8.0\\include\\mysql.h" "LIBS+=%mysql%\\MySQL Server 8.0\\lib\\libmysql.dll"  -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    
    nmake sub-mysql
    
    pause
    

    the output is:

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

  • Lifetime Qt Champion

    @lucaynnofrota said in QTDriver not Load:

    set mysql=C:\Program Files\MySQL

    You should avoid using paths with spaces.


  • Lifetime Qt Champion

    To add to @jsulm or at least you should quote them properly.



  • @lucaynnofrota
    I'm lost: Is your problem still that you don't start out in the right directory for your qmake command?? Because you have been showing lines like:

    C:\Users\lucya\Desktop\Qt Driver>cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    
    C:\Users\lucya\Desktop\Qt Driver>qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\\lib\\libmysql.lib" -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    

    Given that you seem to want to change the current directory to a path on a different drive from where you are, what do you think your first cd is accomplishing? On Windows/DOS it does not change the "current" directory (as you can see from the second line's prompt), it only changes the default directory on the other drive (D:).

    You have to use cd /d ... or pushd ..., or go D:, if drive letter is different from current drive, if you want to change "the current directory" for the qmake.

    Is this what this is all about?? Or maybe I'm going mad or don't have a clue what the issue is :)



  • @JonB
    I forgot this. But i think this is not the problem. Because i can copy the files to correctly directory.
    Anyway, i changed the code!

    Thaks for reply



  • @jsulm
    Thanks for reply
    I copied the files of interest to another folder to try to build. But it did not work.
    Input:

    d:
    cd D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=C:\Users\lucya\Desktop\Qt_Driver\include" "LIBS+=C:\Users\lucya\Desktop\Qt_Driver\libs"  -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    nmake C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql
    
    pause
    

    Output:

    D:\>cd D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql
    
    D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\Users\lucya\Desktop\Qt_Driver\include" "LIBS+=C:\Users\lucya\Desktop\Qt_Driver\libs"  -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
    Info: creating stash file D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql\.qmake.stash
    
    Running configuration tests...
    Checking for DB2 (IBM)... no
    Checking for InterBase... no
    Checking for MySQL... no
    Checking for OCI (Oracle)... no
    Checking for ODBC... yes
    Checking for PostgreSQL... no
    Checking for SQLite (version 2)... no
    Checking for TDS (Sybase)... no
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... yes
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'mingw32-make'.
    Once everything is built, Qt is installed.
    You should NOT run 'mingw32-make install'.
    Note that this build cannot be deployed to other machines or devices.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    
    
    D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>nmake C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql
    
    Microsoft (R) Program Maintenance Utility Version 14.16.27023.1
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    NMAKE : fatal error U1073: don't know how to make 'C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql'
    Stop.
    
    D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>pause
    

    What is "sub" in documentation?


  • Lifetime Qt Champion

    @lucaynnofrota said in QTDriver not Load:

    What is "sub" in documentation?

    What sub do you mean?



  • @jsulm

    Thanks for reply
    http://doc.qt.io/qt-5/sql-driver.html
    Exist this code in documentation

    cd $QTDIR/qtbase/src/plugins/sqldrivers
    qmake -- MYSQL_PREFIX=/usr/local
    make sub-mysql
    

    What is this "sub"?


  • Lifetime Qt Champion

    @lucaynnofrota It is a build target. Open the generated Makefile and search for sub-mysql there.



  • 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!


  • Lifetime Qt Champion

    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.



  • 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
    

  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

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



  • @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?


  • Lifetime Qt Champion

    @ankurboruah This file is created when you configure Qt.



  • @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.


  • Lifetime Qt Champion

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



  • 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


Log in to reply