Solved MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work
-
@MostafaEzzat
If you are having a "Driver not loaded" and don't know why, run your executable with environment variableQT_DEBUG_PLUGINS=1
for diagnostic information. -
Sorry where should i put this variable QT_DEBUG_PLUGINS=1
do you mean by the environment .pro file ? or Options in qtcreator
-
@MostafaEzzat If you start from QtCreator then set it under "Projects/Build & Run/Run/Run Environment"
-
ok i went to Build Enviroment and added it , this output it seems it doesn't search for any sql plugins even he didn't search in
qtbase/src/plugins/sqldrivers
14:27:19: Starting C:\Users\Mostafa\Downloads\HospitalSoftware Last Version\build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug\debug\Hospital-ClinicSoftware.exe ... QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/platforms" ... QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/platforms/qdirect2d.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/platforms/qdirect2d.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "direct2d" ] }, "archreq": 0, "className": "QWindowsDirect2DIntegrationPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("direct2d") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/platforms/qminimal.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/platforms/qminimal.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archreq": 0, "className": "QMinimalIntegrationPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("minimal") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/platforms/qoffscreen.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/platforms/qoffscreen.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archreq": 0, "className": "QOffscreenIntegrationPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("offscreen") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/platforms/qwindows.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/platforms/qwindows.dll, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "windows" ] }, "archreq": 0, "className": "QWindowsIntegrationPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("windows") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/platforms" ... loaded library "D:/Qt/5.15.1/mingw81_32/plugins/platforms/qwindows.dll" QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/platformthemes" ... QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/platformthemes/qxdgdesktopportal.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/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": 331520 } Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/platformthemes" ... QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/styles" ... QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/styles/qwindowsvistastyle.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/styles/qwindowsvistastyle.dll, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "windowsvista" ] }, "archreq": 0, "className": "QWindowsVistaStylePlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("windowsvista") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/styles" ... loaded library "D:/Qt/5.15.1/mingw81_32/plugins/styles/qwindowsvistastyle.dll" DEBUG WARNING hello from showingdata QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/accessible" ... QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/accessible" ... QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/iconengines" ... QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/iconengines/qsvgicon.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/iconengines/qsvgicon.dll, metadata= { "IID": "org.qt-project.Qt.QIconEngineFactoryInterface", "MetaData": { "Keys": [ "svg", "svgz", "svg.gz" ] }, "archreq": 0, "className": "QSvgIconPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("svg", "svgz", "svg.gz") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/iconengines" ... QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/imageformats" ... QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qgif.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qgif.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "gif" ], "MimeTypes": [ "image/gif" ] }, "archreq": 0, "className": "QGifPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("gif") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qicns.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qicns.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "icns" ], "MimeTypes": [ "image/x-icns" ] }, "archreq": 0, "className": "QICNSPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("icns") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qico.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qico.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "ico", "cur" ], "MimeTypes": [ "image/vnd.microsoft.icon", "image/vnd.microsoft.icon" ] }, "archreq": 0, "className": "QICOPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("ico", "cur") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qjpeg.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qjpeg.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "jpg", "jpeg" ], "MimeTypes": [ "image/jpeg", "image/jpeg" ] }, "archreq": 0, "className": "QJpegPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("jpg", "jpeg") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qsvg.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qsvg.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "svg", "svgz" ], "MimeTypes": [ "image/svg+xml", "image/svg+xml-compressed" ] }, "archreq": 0, "className": "QSvgPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("svg", "svgz") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtga.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtga.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "tga" ], "MimeTypes": [ "image/x-tga" ] }, "archreq": 0, "className": "QTgaPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("tga") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtiff.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtiff.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "tiff", "tif" ], "MimeTypes": [ "image/tiff", "image/tiff" ] }, "archreq": 0, "className": "QTiffPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("tiff", "tif") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwbmp.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwbmp.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "wbmp" ], "MimeTypes": [ "image/vnd.wap.wbmp" ] }, "archreq": 0, "className": "QWbmpPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("wbmp") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwebp.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwebp.dll, metadata= { "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface", "MetaData": { "Keys": [ "webp" ], "MimeTypes": [ "image/webp" ] }, "archreq": 0, "className": "QWebpPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("webp") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/imageformats" ... loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qgif.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qicns.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qico.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qjpeg.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qsvg.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtga.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qtiff.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwbmp.dll" loaded library "D:/Qt/5.15.1/mingw81_32/plugins/imageformats/qwebp.dll" QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.15.1/mingw81_32/plugins/accessiblebridge" ... QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/accessiblebridge" ...
-
@MostafaEzzat I don't see it trying to load any SQL drivers. Do you have anything in plugins/sqldrivers directory of your Qt installation?
By the way: it should NOT search in qtbase/src/plugins/sqldrivers as that is source code directory, it should search in D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers
-
i copied qsqlmysql4.dll into D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers
and i got this
should i copy qtbase/src/plugins/sqldrivers into D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers files into
Got keys from plugin meta data ("QODBC3", "QODBC") QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlpsql.dll" Found metadata in lib D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlpsql.dll, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "archreq": 0, "className": "QPSQLDriverPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/sqldrivers" ... ("QSQLITE", "QMARIADB", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") Cannot load library D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers\qsqlmysql.dll: Unknown error 0x000000c1. QLibraryPrivate::loadPlugin failed on "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library D:\\Qt\\5.15.1\\mingw81_32\\plugins\\sqldrivers\\qsqlmysql.dll: Unknown error 0x000000c1." QSqlDatabase: QMARIADB driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 Donnne "Driver not loaded Driver not loaded" not Connected QSqlQuery::exec: database not open
-
@MostafaEzzat said in MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work:
i copied qsqlmysql4.dll
From where?
-
neither QMARIADB nor QMYSQL both don't load
and i copied it from qtbase/src/plugins/sqldrivers
the path where i usedD:\Qt\5.15.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:\Program Files (x86)\MariaDB 10.0\include\mysql" MYSQL_LIBDIR="C:\Program Files (x86)\MariaDB 10.0\lib"
-
@MostafaEzzat It still looks like you DO not follow the documentation (https://doc.qt.io/qt-5/sql-driver.html#building-the-drivers): after building you need to do "make install", that will copy the DLLs to your Qt installation.
Also, are you sure you used the correct qmake to build the plug-ins? I'm asking because you used qmake without absolute path. -
@jsulm said in MySql Driver not loaded , Note: i tried all the existed forums problems and didn't work:
I'm asking because you used qmake without absolute path.
And because the plugin name is wrong - the '4' looks suspicious.
-
i did use
mingw32-make sub-mysql then mingw32-make install
but i'm not sure i use the right path because i was running this software on linux before
but this my .pro file
should i change the path from .pro file or options#------------------------------------------------- # # Project created by QtCreator 2018-12-24T22:54:39 # #------------------------------------------------- # QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets designer TARGET = Hospital-ClinicSoftware TEMPLATE += app lib libs # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 designer plugins plugin SOURCES += \ main.cpp \ mainwindow.cpp \ mainprocess.cpp \ mysqldatabase.cpp \ showingdata.cpp \ delgate.cpp \ profile3.cpp \ profile.cpp \ multipagewidget.cpp \ multipagewidgetplugin.cpp \ multipagewidgetcontainerextension.cpp \ multipagewidgetextensionfactory.cpp \ mysqldatabase.cpp HEADERS += \ mainwindow.h \ mainprocess.h \ showingdata.h \ delgate.h \ profile3.h \ profile.h \ multipagewidget.h \ multipagewidgetplugin.h \ multipagewidgetcontainerextension.h \ multipagewidgetextensionfactory.h \ mysqldatabase.h FORMS += \ mainwindow.ui \ mainprocess.ui \ showingdata.ui \ profile3.ui \ profile.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path += /opt/$${TARGET}/bin $$[QT_INSTALL_PLUGINS]/designer !isEmpty(target.path): INSTALLS += target
-
@MostafaEzzat You should call qmake using whole path to make sure you use the one from the Qt version you're building for.
-
such a weird thing , i didn't know that i should copy libmysql.dll to D:\Qt\5.15.1\mingw81_32\plugins\sqldrivers
i only copied to mingw81_32/bin
now it's working
Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Mostafa/Downloads/HospitalSoftware Last Version/build-Hospital-ClinicSoftware-Desktop_Qt_5_15_1_MinGW_32_bit-Debug/debug/sqldrivers" ... ("QSQLITE", "QMARIADB", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") loaded library "D:/Qt/5.15.1/mingw81_32/plugins/sqldrivers/qsqlmysql.dll" Donnne Connected
Thank you guys i do love this community
-
@MostafaEzzat Yes, plug-ins are somewhat special: they are expected to be in a specific location and are loaded at runtime.