QMYSQL driver not loaded and Library mysql is not defined
-
Hello.
I'm kind of new in QT dev, I am using Windows 10 and QT version 5.12.11.
I'm working on a QT project involving databases, the project was first developed to use a QSQLITE database, but I have to use QMYSQL now. Once I tried to run the project with QMYSQL, I got the error:QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
After searching a bit, I found that I have to compile the QMYSQL driver, so I made some research and found this QT doc page:
https://doc.qt.io/qt-5/sql-driver.htmlAfter installing the C++ connector, I checked my mysql dir, but can't find lib or include folder for the required files, so I tried to install the mysql server as indicated next in the same doc page.
Then I finally found the required file in the right folders:
C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.dll C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib C:\Program Files\MySQL\MySQL Server 8.0\include\mysql.h
The next step you can read in this doc page was to use qmake to compile the driver.
So I try this, replacing the SQL connector folder with SQL server as follow:
qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0/include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
My powershell just didn't recognize the qmake command.
I searched to maybe install qmake or something, found this page:
https://doc.qt.io/archives/3.3/qmake-manual-2.html
The firsts steps about editing environment variables was easy to do.
But just after that, I have to go in qmake dir from QT dir (C:\QT\qmake) but there is no such directory in my QT folder.
Does anyone have an idea or some questions about it?
Thanks
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
My powershell just didn't recognize the qmake command.
qmake is part of a Qt installation. Just use absolute path to qmake.exe from your Qt setup.
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
Does anyone have an idea or some questions about it?
It is not easy but follow this https://forum.qt.io/post/656068 and it should work
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
but what should I do with this path? What do you mean by Qt setup?
Have you looked at https://forum.qt.io/post/656068?
To be able to run qmake, you have to setup environment variables.
All step are described in this post.
Follow it and you should be able to build the MySQL plugin -
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
but what should I do with this path?
Well, use it?
C:\Qt\5.12.11\msvc2017\bin\qmake.exe -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0/include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
But you also should read what @KroMignon suggested in the thread he linked.
-
@KroMignon Yeah sorry I am restricted to a single post every 10 minutes..
I tried your solution, uninstalled my connector version, installed the C connector v 6.1.5, but I connot find the Qt console you are talking about in your post. -
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
but I connot find the Qt console
Look for Qt entry in Windows start menu
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
I tried your solution, uninstalled my connector version, installed the C connector v 6.1.5, but I connot find the Qt console you are talking about in your post.
This entry simply opens a command line window and directly calls
qtenv2.bat
.
If you cannot find it, you can do it by hand.
In you current console, simple executeC:\Qt\5.12.11\msvc2017\bin\qtenv2.bat
After that, setup MSVC envrionnement, and then you can useqmake
. -
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
You solution works, but I have another error:
Wrong directory. And please post the text, no screenshots.
-
@Christian-Ehrlicher oh sorry for screen instead of text..
I changed the INCDIR AND LIBDIR as followed:C:\Qt\5.12.11\msvc2017\bin\qmake.exe -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\lib"
But I still get the same error:
Cannot read C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory Project ERROR: Library 'mysql' is not defined.
Did I misunderstood what you called wrong directory?
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
Did I misunderstood what you called wrong directory?
Yes. You have to call it in the sqldrivers directory as shown in the documentation.
-
@Christian-Ehrlicher Ok so update!
I'm doing this:C:\Qt\5.12.11\msvc2017\bin\qmake.exe -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\lib"
get this:
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 Qt is now configured for building. Just run 'nmake'. Once everything is built, you must run 'nmake install'. Qt will be installed into 'C:\Qt\5.12.11\msvc2017'. Prior to reconfiguration, make sure you remove any leftovers from the previous build.
Then, I run nmake:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe"
get this:
Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. cd sqlite\ && ( if not exist Makefile C:\Qt\5.12.11\msvc2017\bin\qmake.exe -o Makefile C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile.Release all Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. rc /NOLOGO -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -fo .obj\release\qsqlite_resource.res qsqlite_resource.rc cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -Zi -MD -std:c++17 -utf-8 /wd4530 /wd4577 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /Fd.obj\release\qsqlite.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\release -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\release\ @C:\Users\marco\AppData\Local\Temp\nmC4FC.tmp qsql_sqlite.cpp smain.cpp Génération de code en cours... cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -O2 -Zi -MD -utf-8 -W3 -w44456 -w44457 -w44458 /Fd.obj\release\qsqlite.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\release -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\release\ @C:\Users\marco\AppData\Local\Temp\nmD2C9.tmp sqlite3.c cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -Zi -MD -std:c++17 -utf-8 /wd4530 /wd4577 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /Fd.obj\release\qsqlite.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\release -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\release\ @C:\Users\marco\AppData\Local\Temp\nm17B.tmp moc_qsql_sqlite_p.cpp link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /OPT:REF /INCREMENTAL:NO /DLL /SUBSYSTEM:WINDOWS /VERSION:5.12 /OUT:..\plugins\sqldrivers\qsqlite.dll @C:\Users\marco\AppData\Local\Temp\nm499.tmp Création de la bibliothèque ..\plugins\sqldrivers\qsqlite.lib et de l'objet ..\plugins\sqldrivers\qsqlite.exp "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile.Debug all Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. cl -BxC:\Qt\5.12.11\msvc2017\bin\qmake.exe -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -utf-8 /wd4530 /wd4577 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E C:\Qt\5.12.11\msvc2017\mkspecs\features\data\dummy.cpp 2>NUL >.moc\debug\moc_predefs.h C:\Qt\5.12.11\msvc2017\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL --compiler-flavor=msvc --include C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/sqlite/.moc/debug/moc_predefs.h -IC:/Qt/5.12.11/msvc2017/mkspecs/win32-msvc -IC:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/sqlite -IC:/Qt/5.12.11/Src/qtbase/src/3rdparty/sqlite -IC:/Qt/5.12.11/msvc2017/include/QtSql/5.12.11 -IC:/Qt/5.12.11/msvc2017/include/QtSql/5.12.11/QtSql -IC:/Qt/5.12.11/msvc2017/include/QtCore/5.12.11 -IC:/Qt/5.12.11/msvc2017/include/QtCore/5.12.11/QtCore -IC:/Qt/5.12.11/msvc2017/include -IC:/Qt/5.12.11/msvc2017/include/QtSql -IC:/Qt/5.12.11/msvc2017/include/QtCore -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" smain.cpp -o .moc\debug\smain.moc C:\Qt\5.12.11\msvc2017\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL --compiler-flavor=msvc --include C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/sqlite/.moc/debug/moc_predefs.h -IC:/Qt/5.12.11/msvc2017/mkspecs/win32-msvc -IC:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/sqlite -IC:/Qt/5.12.11/Src/qtbase/src/3rdparty/sqlite -IC:/Qt/5.12.11/msvc2017/include/QtSql/5.12.11 -IC:/Qt/5.12.11/msvc2017/include/QtSql/5.12.11/QtSql -IC:/Qt/5.12.11/msvc2017/include/QtCore/5.12.11 -IC:/Qt/5.12.11/msvc2017/include/QtCore/5.12.11/QtCore -IC:/Qt/5.12.11/msvc2017/include -IC:/Qt/5.12.11/msvc2017/include/QtSql -IC:/Qt/5.12.11/msvc2017/include/QtCore -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" qsql_sqlite_p.h -o .moc\debug\moc_qsql_sqlite_p.cpp rc /NOLOGO -D_DEBUG -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -fo .obj\debug\qsqlited_resource.res qsqlited_resource.rc cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -utf-8 /wd4530 /wd4577 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /Fd.obj\debug\qsqlited.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\debug -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\debug\ @C:\Users\marco\AppData\Local\Temp\nmFC1.tmp qsql_sqlite.cpp smain.cpp Génération de code en cours... cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W3 -w44456 -w44457 -w44458 /Fd.obj\debug\qsqlited.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\debug -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\debug\ @C:\Users\marco\AppData\Local\Temp\nm1938.tmp sqlite3.c cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -utf-8 /wd4530 /wd4577 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /Fd.obj\debug\qsqlited.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -I. -IC:\Qt\5.12.11\Src\qtbase\src\3rdparty\sqlite -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtSql\5.12.11\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11 -IC:\Qt\5.12.11\msvc2017\include\QtCore\5.12.11\QtCore -IC:\Qt\5.12.11\msvc2017\include -IC:\Qt\5.12.11\msvc2017\include\QtSql -IC:\Qt\5.12.11\msvc2017\include\QtCore -I.moc\debug -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo.obj\debug\ @C:\Users\marco\AppData\Local\Temp\nm1E98.tmp moc_qsql_sqlite_p.cpp link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /SUBSYSTEM:WINDOWS /VERSION:5.12 /OUT:..\plugins\sqldrivers\qsqlited.dll @C:\Users\marco\AppData\Local\Temp\nm21E5.tmp Création de la bibliothèque ..\plugins\sqldrivers\qsqlited.lib et de l'objet ..\plugins\sqldrivers\qsqlited.exp
run the install command:
C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" install
get this output:
Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. cd sqlite\ && ( if not exist Makefile C:\Qt\5.12.11\msvc2017\bin\qmake.exe -o Makefile C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile install Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile.Release install Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. copy /y ..\plugins\sqldrivers\qsqlite.dll C:\Qt\5.12.11\msvc2017\plugins\sqldrivers\qsqlite.dll 1 fichier(s) copié(s). copy /y ..\plugins\sqldrivers\qsqlite.pdb C:\Qt\5.12.11\msvc2017\plugins\sqldrivers\qsqlite.pdb 1 fichier(s) copié(s). C:\Qt\5.12.11\msvc2017\bin\qmake.exe -install qinstall C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake C:\Qt\5.12.11\msvc2017\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x86\nmake.exe" -f Makefile.Debug install Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 Copyright (C) Microsoft Corporation. Tous droits réservés. copy /y ..\plugins\sqldrivers\qsqlited.dll C:\Qt\5.12.11\msvc2017\plugins\sqldrivers\qsqlited.dll 1 fichier(s) copié(s). copy /y ..\plugins\sqldrivers\qsqlited.pdb C:\Qt\5.12.11\msvc2017\plugins\sqldrivers\qsqlited.pdb 1 fichier(s) copié(s). C:\Qt\5.12.11\msvc2017\bin\qmake.exe -install qinstall C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake C:\Qt\5.12.11\msvc2017\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake
I checked the config.log, as said in the doc, and lines talking about mysql are:
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:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && C:\Qt\5.12.11\msvc2017\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\opensslx86\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresqlx86\\pgsql\\lib" "INCLUDEPATH += C:\\opensslx86\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresqlx86\\pgsql\\include" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = \"C:\\Program Files\\MySQL\\MySQL Connector C 6.1\\lib/libmysql.lib\"" "QMAKE_INCDIR_MYSQL = \"C:\\Program Files\\MySQL\\MySQL Connector C 6.1\\include\"" C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql > Info: creating stash file C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\.qmake.stash + cd /d C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 > Copyright (C) Microsoft Corporation. Tous droits réservés. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -I. -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -I"C:\Program Files\MySQL\MySQL Connector C 6.1\include" -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo @C:\Users\marco\AppData\Local\Temp\nmAFE1.tmp > main.cpp > link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:mysql.exe @C:\Users\marco\AppData\Local\Temp\nmB1C6.tmp > main.obj : error LNK2019: symbole externe non r‚solu _mysql_get_client_version@0 r‚f‚renc‚ dans la fonction _main > C:\Program Files\MySQL\MySQL Connector C 6.1\lib\libmysql.lib : warning LNK4272: type d'ordinateur bibliothŠque 'x64' en conflit avec le type d'ordinateur cible 'x86' > mysql.exe : fatal error LNK1120: 1 externes non r‚solus > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\link.EXE"' : code retour '0x460' > Stop. => source failed verification. Trying source 6 (type inline) of library mysql ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.mysql FAILED
I tried to delete config.cache as said in doc, but same results..
And of course, while trying to run my app:
QML debugging is enabled. Only use this in a safe environment. QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
Honnestly I'm kinda lost in technical informations..
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
MySql .................................. no
As you can see MySql was disabled.
Check the config.log file to see why. -
@jsulm I thought it was the already installed ones.
I've put the part about mysql from the config.log in my previous message, but I will link the whole file bellow.Command line: "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Connector C 6.1\include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Connector C 6.1\lib" Global lib dirs: [C:\\opensslx86\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresqlx86\\pgsql\\lib] ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\lib\\x64" "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.18362.0\\ucrt\\x64" "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.18362.0\\um\\x64"] Global inc dirs: [C:\\opensslx86\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresqlx86\\pgsql\\include] ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\include" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\ucrt" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\winrt" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\cppwinrt"] looking for library db2 Trying source 0 (type inline) of library db2 ... None of [db2cli.lib] found in [] and global paths. => source produced no result. 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 ... None of [gds32_ms.lib] found in [] and global paths. => source produced no result. 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:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && C:\Qt\5.12.11\msvc2017\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\opensslx86\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresqlx86\\pgsql\\lib" "INCLUDEPATH += C:\\opensslx86\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresqlx86\\pgsql\\include" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = \"C:\\Program Files\\MySQL\\MySQL Connector C 6.1\\lib/libmysql.lib\"" "QMAKE_INCDIR_MYSQL = \"C:\\Program Files\\MySQL\\MySQL Connector C 6.1\\include\"" C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql > Info: creating stash file C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\.qmake.stash + cd /d C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 > Copyright (C) Microsoft Corporation. Tous droits réservés. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -I. -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -I"C:\Program Files\MySQL\MySQL Connector C 6.1\include" -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo @C:\Users\marco\AppData\Local\Temp\nmAFE1.tmp > main.cpp > link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:mysql.exe @C:\Users\marco\AppData\Local\Temp\nmB1C6.tmp > main.obj : error LNK2019: symbole externe non r‚solu _mysql_get_client_version@0 r‚f‚renc‚ dans la fonction _main > C:\Program Files\MySQL\MySQL Connector C 6.1\lib\libmysql.lib : warning LNK4272: type d'ordinateur bibliothŠque 'x64' en conflit avec le type d'ordinateur cible 'x86' > mysql.exe : fatal error LNK1120: 1 externes non r‚solus > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\link.EXE"' : code retour '0x460' > Stop. => 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 ... None of [oci.lib] found in [] and global paths. => source produced no result. 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:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\odbc && C:\Qt\5.12.11\msvc2017\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\opensslx86\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresqlx86\\pgsql\\lib" "INCLUDEPATH += C:\\opensslx86\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresqlx86\\pgsql\\include" "QMAKE_USE += odbc" "QMAKE_LIBS_ODBC = \"C:\\Program Files ^(x86^)\\Windows Kits\\10\\lib\\10.0.18362.0\\um\\x64/odbc32.lib\"" C:/Qt/5.12.11/Src/qtbase/src/plugins/sqldrivers/config.tests/odbc + cd /d C:\Qt\5.12.11\Src\qtbase\src\plugins\sqldrivers\config.tests\odbc && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.26.28806.0 > Copyright (C) Microsoft Corporation. Tous droits réservés. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DNDEBUG -I. -IC:\opensslx86\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresqlx86\pgsql\include -IC:\Qt\5.12.11\msvc2017\mkspecs\win32-msvc -Fo @C:\Users\marco\AppData\Local\Temp\nmB33C.tmp > main.cpp > link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:odbc.exe @C:\Users\marco\AppData\Local\Temp\nmB502.tmp > main.obj : error LNK2019: symbole externe non r‚solu _SQLAllocHandle@12 r‚f‚renc‚ dans la fonction _main > C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64\odbc32.lib : warning LNK4272: type d'ordinateur bibliothŠque 'x64' en conflit avec le type d'ordinateur cible 'x86' > odbc.exe : fatal error LNK1120: 1 externes non r‚solus > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\link.EXE"' : code retour '0x460' > Stop. => source failed verification. Trying source 1 (type inline) of library odbc ... => source failed condition 'config.darwin'. Trying source 2 (type inline) of library odbc ... => source failed condition '!config.win32 && !config.darwin'. test config.sqldrivers.libraries.odbc FAILED 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 ... None of [libpq.lib] found in [] and global paths. => source produced no result. 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 ... None of [sqlite.lib] found in [] and global paths. => source produced no result. test config.sqldrivers.libraries.sqlite2 FAILED looking for library tds Trying source 0 (type sybaseEnv) of library tds ... None of [NTWDBLIB.lib] found in [] and global paths. => source produced no result. Trying source 1 (type sybaseEnv) of library tds ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.tds FAILED
I don't really understand all of this.
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
C:\Program Files\MySQL\MySQL Connector C 6.1\lib\libmysql.lib : warning LNK4272: type d'ordinateur bibliothŠque 'x64' en conflit avec le type d'ordinateur cible 'x86'
This is the problem: your Qt and MySql lib are for different architectures.
-
@Markyo said in QMYSQL driver not loaded and Library mysql is not defined:
Wich one should I choose?
The one you need.
It looks like you installed Qt x86, right? Install Qt x86_64 and use that one.