build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded
-
@cpplegend No, there are always things one has to learn when doing something for the first time :-)
-
@jsulm thank you..
by the way it doesn't workwhen I build it I get this:
[15/25] Building RC object mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
FAILED: mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQMYSQLDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql/QMYSQLDriverPlugin_autogen/include -I C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/mysql -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/include -I "C:/Program Files/MySQL/MySQL Connector C 6.1/include" -I C:/Qt/6.5.1/mingw_64/include/QtCore -I C:/Qt/6.5.1/mingw_64/include -I C:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -I C:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -I C:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -I C:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -I C:/Qt/6.5.1/mingw_64/include/QtSql C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql/QMYSQLDriverPlugin_resource.rc mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
cc1.exe: fatal error: Files/MySQL/MySQL: No such file or directory
compilation terminated.
cc1.exe: fatal error: Connector: No such file or directory
compilation terminated.
cc1.exe: fatal error: C: No such file or directory
compilation terminated.
cc1.exe: fatal error: 6.1/include: No such file or directory
compilation terminated.
C:\Qt\Tools\mingw1120_64\bin\windres.exe: preprocessing failed.
[22/25] Building C object sqlite/CMakeFiles/QSQLiteDriverPlugin.dir/C_/Qt/6.5.1/Src/qtbase/src/3rdparty/sqlite/sqlite3.c.obj
ninja: build stopped: subcommand failed. -
@cpplegend said in build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded:
cc1.exe: fatal error: Files/MySQL/MySQL: No such file or directory
You have paths with spaces which are often problematic, just like in this case.
Install the MySQL client lib in a folder without spaces. -
@jsulm it still doesn't work, it's another error now: [15/25] Building RC object mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
FAILED: mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQMYSQLDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql/QMYSQLDriverPlugin_autogen/include -I C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/mysql -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql -I C:/Qt/6.5.1/mingw_64/build-sqldrivers/include -I "C:/Program Files/MySQL/MySQL_ConnectorC6.1/include" -I C:/Qt/6.5.1/mingw_64/include/QtCore -I C:/Qt/6.5.1/mingw_64/include -I C:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -I C:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -I C:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -I C:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -I C:/Qt/6.5.1/mingw_64/include/QtSql C:/Qt/6.5.1/mingw_64/build-sqldrivers/mysql/QMYSQLDriverPlugin_resource.rc mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj
cc1.exe: fatal error: Files/MySQL/MySQL_ConnectorC6.1/include: No such file or directory
compilation terminated.
C:\Qt\Tools\mingw1120_64\bin\windres.exe: preprocessing failed.
[22/25] Building C object sqlite/CMakeFiles/QSQLiteDriverPlugin.dir/C_/Qt/6.5.1/Src/qtbase/src/3rdparty/sqlite/sqlite3.c.obj
ninja: build stopped: subcommand failed. -
@cpplegend said in build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded:
it's another error now
It's same type of error - you have spaces in your paths.
Did you install the client library in a path without spaces?
If so then please start from clean build folder. -
@cpplegend said in build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded:
because I am italian the name was "programmi"
Yes, Windows tries to hide things from the user :-)
-
@jsulm yeah... now it worked thank you I am so happy, I have been trying to build this driver for 4 days, now it worked and I have the build, now it should work or I have to do anything else? because I tried to instantiate a connection to a database in mysql and it doesn't work, it still says Driver not loaded.
-
@cpplegend Did you also did "make install" step?
To debug plug-in problems you can set QT_DEBUG_PLUGINS variable before running the app and check the output. See https://doc.qt.io/qt-6/debug.html
My guess is that the MySQL client library cannot be found. I'm not sure, but I think you need to copy it to same location as the plug-in. -
@cpplegend said in build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded:
what should I do now?
Set QT_DEBUG_PLUGINS env variable before starting your app. Either in QtCreator in "Run Environment" of your project or, if you start your app manually in a terminal, using "export QT_DEBUG_PLUGINS=1". Then check the output of the application to see why the plug-in is not loaded.
-
@jsulm said in build QMYSQL driver under windows 10, a sample solution for QSqlDatabase: QMYSQL driver not loaded:
using "export QT_DEBUG_PLUGINS=1".
@cpplegend
Since you are using Windows this would beset QT_DEBUG_PLUGINS=1
in a Command Prompt window. -