Getting crazy with "driver not loaded" mysql driver in windows 7 (mingw 32bit)
-
Hello everybody!
Sorry for my English, I don't speak or write often it.
This is the third day that I'm struggling whit this plugin, before this post I have looked everywhere in this forum (and others), without find the solution.The code:
db = new QSqlDatabase(); qDebug() << "drivers:" db->drivers(); db->setHostName("localhost"); qDebug() << db->addDatabase("QMYSQL3"); qDebug() << "Valid? "<< db->isValid(); // Returns true if connection exists qDebug() << db->lastError();
And the output:
drivers: ("QMYSQL", "QMYSQL3")
QSqlDatabase(driver="QMYSQL3", database="", host="", port=-1, user="", open=false)
Valid? false
QSqlError("", "Driver not loaded", "Driver not loaded")I use it on Ubuntu with succes, but now, in windows it seems there's no way to make it work.
I tried the prebuilt plugin, and also the compiled one from source code after watching a lot of tutorial, guide ecc.I already:
- Added to the environment path (both in qt and in windows) of minwg "bin", mysql "lib" qt "bin" folder.
- Copied libmysql.dll and mysqlclient.lib (from mysql directory) to each directory possible
- Included mysql library directories to the project with:
QMAKE_LIBDIR += "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
LIBS += libmysql - tried with visual studio compiler version
- installed and tried 4 different version of mysql (and XAMPP)
- generated: libmysql.def and libmysql.a with reimp and dlltool command
- the pointer to QSqlDatabase is allocated after QApplication has initialized
As you can see, the qsqlmysql.dll driver is recognized but the driver isn't loaded, why?
What should I have been wrong? -
Hi and welcome to devnet,
Please search the forum a bit, that question has already been asked many times.
You likely don't have the MySQL client DLL not accessible through your PATH environment variable so it can be found and thus the driver fails to load. One simple way of changing this is to go to the Run part of the Project panel and modify the PATH environment variable by adding the path to the MySQL client DLLS containing folder.
-
Hello! Thank you for so fast reply.
I looked a lot in the forum, I swear! Three days, maybe I'm no so much able to understand the procedures.
So, I have already update the path (like I wrote in the first item point of my post):Maybe I don't understand whatever I have to add, the test selectioned is the path of libmysql.lib, or not?
-
The question might be silly but are you sure that the DLLs (not the .lib files) are there ?
-
Yes should be.
So next step: add QT_DEBUG_PLUGINS 1 to the environment variable, you should see more information about what is happening at load time.
-
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 328960
}"The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimal.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
not a plugin
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimald.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qminimald.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"className": "QMinimalIntegrationPlugin",
"debug": true,
"version": 328960
}Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 328960
}"The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreen.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
not a plugin
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreend.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qoffscreend.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"className": "QOffscreenIntegrationPlugin",
"debug": true,
"version": 328960
}Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"windows"
]
},
"className": "QWindowsIntegrationPlugin",
"debug": false,
"version": 328960
}"The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindows.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
not a plugin
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"windows"
]
},
"className": "QWindowsIntegrationPlugin",
"debug": true,
"version": 328960
}Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platforms" ...
loaded library "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforms/qwindowsd.dll"
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/platforminputcontexts" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/platforminputcontexts" ...
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/styles" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/styles" ...
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines" ...
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll, metadata=
{
"IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
"MetaData": {
"Keys": [
"svg",
"svgz",
"svg.gz"
]
},
"className": "QSvgIconPlugin",
"debug": false,
"version": 328960
}"The plugin 'D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicon.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
not a plugin
QFactoryLoader::QFactoryLoader() looking at "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicond.dll"
Found metadata in lib D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/iconengines/qsvgicond.dll, metadata=
{
"IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
"MetaData": {
"Keys": [
"svg",
"svgz",
"svg.gz"
]
},
"className": "QSvgIconPlugin",
"debug": true,
"version": 328960
}Got keys from plugin meta data ("svg", "svgz", "svg.gz")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/iconengines" ...
"C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug"
QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/Qt5.5.0/5.5/mingw492_32/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Andrea/Documents/build-provadb-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/accessiblebridge" ... -
Ok, I missed you wrote MinGW in your title. IIRC MySQL is built with Visual Studio. So you need to build the libraries with MinGW.
-
Unfortunately it appear difficult to find the source code that can be compiled with the latest version of cmake and mingw, I tried and had several building error.
I found this link: Compiling mysql connector C++ with mingw, compiling errors in wich there are the same errors.
I misunderstood or it seems that anyone that want to use the qt plugin for mysql (with mingw) have to use a 4 or 5 years old source code? Maybe I should switch to visual studio compiler?
-
That I can't comment on. You should ask the MySQL people about that matter.