Cannot load mysql dll plugin on windows 10
-
wrote on 25 Mar 2021, 10:26 last edited by rhx9
Hi,
I've built a pyqt app that uses qsqlmysql plugin, I developed the app on Linux thinking that as qt and pyqt are cross-platform I would have no problem when deploying the app to my customer who uses windows 10 machine, but I was wrong, I've been messing around with getting the qsqlmysql plugin to work on the windows 10 machine for over 3 weeks and I couldn't get it to work.
after messing around for some days I found out that even a cpp doesn't load the plugin correctly, so here I'm providing my problem using cpp and plain QT (no PyQt) to try and solve it from the Qt part and then try to solve the PyQt part.what I did Is I used a prebuilt dll from this repo https://github.com/thecodemonkey86/qt_mysql_driver
and placed it in the right path in "C:\Qt\Qt5.14.2\5.14.2\msvc2017_64\plugins\sqldrivers" along with its dependencies (I checked the dll with dependencies and everything seems fine but when I run an application it fails to load the plugin.The test code I used
#include <QApplication> #include <QString> #include <QtSql> int main(int argc, char *argv[]) { QApplication app(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("127.0.0.1"); db.setDatabaseName("test_db"); db.setUserName("test_user"); db.setPassword("password"); bool ok = db.open(); }
The output I get when running the app:
13:58:21: Starting C:\Users\mohammad\Desktop\build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\debug\example.exe ... QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms" ... QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qdirect2d.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qdirect2d.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "direct2d" ] }, "archreq": 0, "className": "QWindowsDirect2DIntegrationPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qdirect2d.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qdirect2dd.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qdirect2dd.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "direct2d" ] }, "archreq": 1, "className": "QWindowsDirect2DIntegrationPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("direct2d") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qminimal.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qminimal.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archreq": 0, "className": "QMinimalIntegrationPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qminimal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qminimald.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qminimald.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archreq": 1, "className": "QMinimalIntegrationPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("minimal") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qoffscreen.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qoffscreen.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archreq": 0, "className": "QOffscreenIntegrationPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qoffscreen.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qoffscreend.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qoffscreend.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archreq": 1, "className": "QOffscreenIntegrationPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("offscreen") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindows.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindows.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "windows" ] }, "archreq": 0, "className": "QWindowsIntegrationPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindows.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindowsd.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindowsd.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "windows" ] }, "archreq": 1, "className": "QWindowsIntegrationPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("windows") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/Desktop/build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/platforms" ... loaded library "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindowsd.dll" QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes" ... QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes/qxdgdesktopportal.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes/qxdgdesktopportal.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1", "MetaData": { "Keys": [ "xdgdesktopportal", "flatpak", "snap" ] }, "archreq": 0, "className": "QXdgDesktopPortalThemePlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes/qxdgdesktopportal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes/qxdgdesktopportald.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platformthemes/qxdgdesktopportald.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1", "MetaData": { "Keys": [ "xdgdesktopportal", "flatpak", "snap" ] }, "archreq": 1, "className": "QXdgDesktopPortalThemePlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/Desktop/build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/platformthemes" ... QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles" ... QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyle.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyle.dll, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "windowsvista" ] }, "archreq": 0, "className": "QWindowsVistaStylePlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyle.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyled.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyled.dll, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "windowsvista" ] }, "archreq": 1, "className": "QWindowsVistaStylePlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("windowsvista") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/Desktop/build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/styles" ... loaded library "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyled.dll" QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers" ... QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/libmysql.dll" "Failed to extract plugin meta data from 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/libmysql.dll'" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlite.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlite.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "archreq": 0, "className": "QSQLiteDriverPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlite.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlited.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlited.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "archreq": 1, "className": "QSQLiteDriverPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("QSQLITE") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "archreq": 0, "className": "QMYSQLDriverPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysqld.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysqld.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "archreq": 1, "className": "QMYSQLDriverPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("QMYSQL3", "QMYSQL") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlodbc.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlodbc.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QODBC3", "QODBC" ] }, "archreq": 0, "className": "QODBCDriverPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlodbc.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlodbcd.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlodbcd.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QODBC3", "QODBC" ] }, "archreq": 1, "className": "QODBCDriverPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("QODBC3", "QODBC") QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "archreq": 0, "className": "QPSQLDriverPlugin", "debug": false, "version": 331264 } "The plugin 'C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll" Found metadata in lib C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "archreq": 1, "className": "QPSQLDriverPlugin", "debug": true, "version": 331264 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/Desktop/build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/sqldrivers" ... Cannot load library C:\Qt\Qt5.14.2\5.14.2\msvc2017_64\plugins\sqldrivers\qsqlmysqld.dll: The specified module could not be found. QLibraryPrivate::loadPlugin failed on "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysqld.dll" : "Cannot load library C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64\\plugins\\sqldrivers\\qsqlmysqld.dll: The specified module could not be found." QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/styles/qwindowsvistastyled.dll" QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/platforms/qwindowsd.dll" 13:58:21: C:\Users\mohammad\Desktop\build-example-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\debug\example.exe exited with code 0
You can see in the following line :
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
that it is detecting that the MySQL plugin is installed but it can't load it for some reason.
Is there a more verbose option than DEBUG_QT_PLUGINS? an option that shows me where and why exactly is it failing to load.
What might be causing this? i used a dll compiled for the same QT version an by the same compiler and I still can't load it !Regards
-
@rhx9 said in Cannot load mysql dll plugin on windows 10:
bool ok = db.open();
How do you expect that this will work when you don't specify anything (port, hostname, ...)? Please read the docs.
-
@rhx9 said in Cannot load mysql dll plugin on windows 10:
bool ok = db.open();
How do you expect that this will work when you don't specify anything (port, hostname, ...)? Please read the docs.
wrote on 25 Mar 2021, 11:00 last edited by@Christian-Ehrlicher said in Cannot load mysql dll plugin on windows 10:
@rhx9 said in Cannot load mysql dll plugin on windows 10:
bool ok = db.open();
How do you expect that this will work when you don't specify anything (port, hostname, ...)? Please read the docs.
The code I included was just to test the plugin loading and not the connecting routine, anyways I've tested the code with specifying the hostname and other settings the same error applies.
I will update the code in the original post to reflect that -
You have to make sure that the dependent libraries are in your PATH. There are numerous threads about this... searching helps.
-
You have to make sure that the dependent libraries are in your PATH. There are numerous threads about this... searching helps.
wrote on 25 Mar 2021, 11:49 last edited by@Christian-Ehrlicher said in Cannot load mysql dll plugin on windows 10:
You have to make sure that the dependent libraries are in your PATH. There are numerous threads about this... searching helps.
As I've said I've been searching and trying for over three weeks, I placed the dependencies in the system32 folder, I also placed them alongside the qsqlmysql.dll to be sure, I then checked the dll using a dependency checker and everything seems fine,
so I think all the dependencies are installed and detected correctly but there is something else going on.
1/5