Problem with QMYSQL
-
Hi. I know that there's a lot of topics about it, but this is uncommon.
Problem is that qmysql.dll loads ONLY from mingw folder and nothing helps. fighting with this 2 days and cant resolve it.
pls helphere's some code (setting up libs load from exe folder):
QStringList str;
str.append(".");
qApp->setLibraryPaths(str);in PRO:
QTPLUGIN += QSQLMYSQL
QT += sql core gui
-
Hi and welcome to devnet,
If you want the plugin to load when deploying your application, you have to respect the folder hierarchy. So you have to keep plugins/sqldrivers beside your application.
-
Did you also deploy MinGW's dlls ?
One thing you can do is start your application from the command line with the
QT_DEBUG_PLUGINS
environnement variable set to 1.You'll what is happening when your plugins are getting loaded.
-
@sgaist all in there (every folder have from 1 up to 9 dlls)
And this is sqldrivers folder
Problem is that if C:\Qt\5.11.3\mingw53_32\plugins\qsqlmysql.dll exists, all ok. If I remove it - it doesn't loads from exe folder and C:\Deploy\libmysql.dll not loading too.
-
FOUND WHERE'S PROBLEM
But still need help.
Problem is that driver loading before setting up default folder:
QStringList str;
str.append("C:\Deploy");
qApp->setLibraryPaths(str);And getting this err:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
my library path : ("C:\Deploy")Problem in database.cpp:
#include "database.h"
static QSqlDatabase datb = QSqlDatabase::addDatabase("QMYSQL", "datas");
static QSqlQuery query(datb);static QString host = "site.host";
static QString namedb = "name";
static QString nameusr = "usr";
static QString passdb = "pass";
//db login & open
void Database::login_db()
{
}Exact problem in:
static QSqlDatabase datb = QSqlDatabase::addDatabase("QMYSQL", "datas");This line loading before int main(int argc, char *argv[]) and upload's qmysql from default folder of mingw
If I remove it from there and put into login func all with loading is ok:
But doesn't work then my functions. How can I solve it? how to move these lines in another place:
static QSqlDatabase datb= QSqlDatabase::addDatabase("QMYSQL", "datab");
static QSqlQuery query(datb);I mean load 'em later than main.cpp
-
Are you trying to move things around in the folder where you are currently doing the application deployment ?