MYSQL / QT issues
-
Hi Im having issues connecting up QT with MYSQL, I managed to get MYSQL as an available driver, however when trying to connect to a db I get the following:
" QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL"From what I understand Ive not connected qt with mysql, I have a mysql connector as well just need to link them.. I think. I try following the steps in here, but I just dont understand how to run qmake through the cmd line.I match the directory but 'qmake' is not recognized appears as expected, I see no way of opening a qt specific cmd line, I do not gwt the QT for desktop I have seen suggested on other threads and am a bit lost.
-
Hi and welcome to devnet,
Did you already try to run your application with the QT_DEBUG_PLUGINS environment variable set to 1 ?
Because from the looks of it, you have the drivers themselves ready to use.
-
-
The environment variable won't fix your error, it will dump a lot of information about what is going on with your plugins.
As for editing it, do it in the Run part of the Project panel.
-
ahhhh got you the follwing was spat out regarding Mysql:
QFactoryLoader::QFactoryLoader() looking at "C:/Qt/6.2.3/mingw_64/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Qt/6.2.3/mingw_64/plugins/sqldrivers/qsqlmysql.dll, metadata=
"QMYSQL",
"className": "QMYSQLDriverPlugin",
Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
Cannot load library C:\Qt\6.2.3\mingw_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Qt/6.2.3/mingw_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\Qt\6.2.3\mingw_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found."
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL -
Can the connector .dll be found ?
-
Hi sorry not sure where to see this, there was no mention of connector .dll in the debuf_plugin message, I think I need to follow this step: compiling driver. However I dont have a qt command prompt and am struddling to run through the standard windows cmd line. Aslo in looking at other threads, I do not have a .pro in the mysql folder in ~src/plugins/sqldrivers/mysql could this be the issue?
-
Based on the output, you already have the .dll.
As for the MySQL connector .dll, where did you install MySQL ?
-
Then, do you have that path in your PATH environment variable ? (Still in Qt Creator)
-
PATH is already defined, you may have to check a checkbox on the Run panel in order to have access to it.
-
@SGaist I have also tried to compile driver using the following in the command prompt :
C:\Qt\6.2.3\Src\qtbase\src\plugins\sqldrivers>qmake -version
QMake version 3.1
Using Qt version 6.2.3 in C:/Qt/6.2.3/mingw_64/libC:\Qt\6.2.3\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
However it doesnt do anything after the second command, just gives me basic qmkae info.
-
Hi, I couldnt find the PATH variable but ran this command in main.cpp:
QCoreApplication::addLibraryPath("C:\Program Files\MySQL");
However this didnt change any of the logs. Im a bit lost with where to go from here@Jdonoher said in MYSQL / QT issues:
QCoreApplication::addLibraryPath("C:\Program Files\MySQL");
Did you really copy and paste this line from your C++ source code file? Please copy and paste whatever you have literally, do not type it in by hand.....
-
@Jdonoher said in MYSQL / QT issues:
QCoreApplication::addLibraryPath("C:\Program Files\MySQL");
Did you really copy and paste this line from your C++ source code file? Please copy and paste whatever you have literally, do not type it in by hand.....
-
-
I've alslo managed to finally get .pro file in my /mysql dir in src. However it cannot build, I have included the include path from the mysql connector as well as added the lib to LIBS. but am getting 3 errors:
Here is mysql.pro file:
-
@Jdonoher
I could be wrong, but because your paths have spaces in them I would have expected them to need to be quoted, like:INCLUDEPATH += "C:/Program Files/MySQl/MySQL Connector C 6.1/include" LIBS += "C:/Program Files/MySQl/MySQL Connector C 6.1/lib"
-
Simply move it to a folder without spaces...