How to create Qt 6.5 mysql driver with cmake?
-
@Saad02 said in How to create Qt 6.5 mysql driver with cmake?:
Do I have to somewhere else except Qt Creator?
No, you just need to do it properly. You need to set QT_DEBUG_PLUGINS=1 in Run settings of your project in QtCreator.
-
@jsulm Sir, you mean that file with ".pro" extension right?
database.pro:
QT += core gui sqlgreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
QT_DEBUG_PLUGINS=1You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
mainwindow.cppHEADERS +=
mainwindow.hFORMS +=
mainwindow.uiDefault rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetNothing changed!
-
@Saad02 said in How to create Qt 6.5 mysql driver with cmake?:
you mean that file with ".pro" extension right?
No, I did not say a single word about the pro file.
You were asked to set QT_DEBUG_PLUGINS anvironment variable to 1 before starting your application.
You can set it in QtCreator if you go to "Projects/Build & Run/Run/Run Environment". -
@Saad02 said in How to create Qt 6.5 mysql driver with cmake?:
I don't have "run environment" in run
Of course you have, you just need to look bellow the part you posted, really...
-
@jsulm Sir, the red marked one showing me my system variables, not run environment variable.
And this is the rest-
Here is all I have in "run".
By the way, the internet connection in our local is currently unstable. Can it be the reason for that driver not to load? -
@Saad02
It seems to clearly show your Run environment, and that by default is the same as your System environment.You have been asked to add a
QT_DEBUG_PLUGINS
environment variable into the Run environment, so do so.Or, just run your executable from a terminal shell and add the environment variable there.
-
@JonB Done and nothing much happened.
Application Output:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQLCompile Output:
18:27:06: Running steps for project database...
18:27:06: Starting: "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" "C:\Users\Saad\Documents\qt c++\database\database.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
18:27:10: The process "C:\Qt\6.5.1\mingw_64\bin\qmake.exe" exited normally.
18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -f "C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug/Makefile" qmake_all
mingw32-make: Nothing to be done for 'qmake_all'.
18:27:10: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
18:27:10: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j4
C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
mingw32-make[1]: Nothing to be done for 'first'.
mingw32-make[1]: Leaving directory 'C:/Users/Saad/Documents/qt c++/build-database-Desktop_Qt_6_5_1_MinGW_64_bit-Debug'
18:27:11: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally.
18:27:11: Elapsed time: 00:05. -
@Saad02
I can only say that, although you seem to have done the right thing, this is not correct output when settingQT_DEBUG_PLUGINS=1
. You can verify that by searching the hundreds of occasions it has been used in this forum's questions or on the web.Since I don't know exactly about Creator I suggest you set it in a shell and run your executable from there.
-
@Saad02 said in How to create Qt 6.5 mysql driver with cmake?:
Application Output:
There should be more output if QT_DEBUG_PLUGINS was set - is that really all you get?
-
@JonB said in How to create Qt 6.5 mysql driver with cmake?:
Since I don't know exactly about Creator I suggest you set it [
set QT_DEBUG_PLUGINS=1
] in a shell and run your executable from there.Did you try this? You have to know how to run your executable outside of Creator, else it will be useless in the the long-term, you cannot always require your code to run inside Creator!
-
@Saad02
I wish you would show a screenshot of what you do in that terminal immediately after theset QT_DEBUG_PLUGINS=1
....If you read through this forum or search the web you will find "hundreds" of occasions where people get a
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
and they set the environment variable, run their application and get diagnostic output as to why it has failed to load
QMYSQL
driver. Not one of them has ever reported it failed to produce the diagnostic output. I find it hard to believe your case is any different..... -
@Saad02
I already suggested you run this in a terminal, not in Creator, so we can see what is going on. Repeatedly showing it is not working from your Creator isn't getting us anywhere.I don't know why you don't see the diagnostic output in Creator.
It occurs to me: when run in terminal I am not sure where you get the diagnostic output under Windows. It may not be in terminal, may have to go to some debugger. You can probably search the forum or elsewhere, I don't use Windows for Qt. Otherwise I leave someone else to suggest.