QMYSQL driver not found Qt 6.5.1, I've tried all I found online, without success
-
@cpplegend you can use different C++ compilers with Qt. On Windows by default these are Microsoft Visual C++ or MinGW. During Installation in Qt maintenance tool you choose if you install the Qt version for MSVC or for MinGW (or both):
.
If you are a beginner, I recommend to install only one of them to avoid confusion. In Qt Creator under "Projects" you should be able to see, which Qt version is used for the current project:
depending on that, you need to copy the correct qsqlmysql.dll (plus libmysql.dll):
If it's MSVC2019 then for example copy the files from https://github.com/thecodemonkey86/qt_mysql_driver/files/11768056/qsqlmysql.dll_Qt_SQL_driver_6.5.1_MSVC2019_64-bit.zip,
if MinGW then the files from https://github.com/thecodemonkey86/qt_mysql_driver/files/11768059/qsqlmysql.dll_Qt_SQL_driver_6.5.1_MinGW_11.2.0_64-bit.zip
to sqldrivers folder and application folder respectively
wrote on 30 Jun 2023, 17:06 last edited by@thecodemonkey sqldrivers from plugin folder in src from qtbase folder, right? and then as you Said the Application folder of the Project I am creating, is it right?
-
@thecodemonkey sqldrivers from plugin folder in src from qtbase folder, right? and then as you Said the Application folder of the Project I am creating, is it right?
wrote on 30 Jun 2023, 17:15 last edited by thecodemonkey@cpplegend by application folder I mean the folder, where the compiler creates the .exe file of your project, like this:
the sqldrivers folder can be either a subdirectory of the application folder (like this:
) ,or in the installation binary folder of Qt. On my system that would be for
MSVC: C:\Qt\6.5.1\msvc2019_64\plugins\sqldrivers (and for MinGW: C:\Qt\6.5.1\mingw_64\plugins\sqldrivers)both options (application folder and installation folder) should work
-
@cpplegend by application folder I mean the folder, where the compiler creates the .exe file of your project, like this:
the sqldrivers folder can be either a subdirectory of the application folder (like this:
) ,or in the installation binary folder of Qt. On my system that would be for
MSVC: C:\Qt\6.5.1\msvc2019_64\plugins\sqldrivers (and for MinGW: C:\Qt\6.5.1\mingw_64\plugins\sqldrivers)both options (application folder and installation folder) should work
wrote on 30 Jun 2023, 17:42 last edited by@thecodemonkey ok when I return home I will try
-
@cpplegend by application folder I mean the folder, where the compiler creates the .exe file of your project, like this:
the sqldrivers folder can be either a subdirectory of the application folder (like this:
) ,or in the installation binary folder of Qt. On my system that would be for
MSVC: C:\Qt\6.5.1\msvc2019_64\plugins\sqldrivers (and for MinGW: C:\Qt\6.5.1\mingw_64\plugins\sqldrivers)both options (application folder and installation folder) should work
wrote on 30 Jun 2023, 20:12 last edited by@thecodemonkey now when I include the QSqlDatabase header file these errors occures: :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x3b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x8b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0xef): undefined reference to__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x14f): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1a9): undefined reference to__imp__ZN12QSqlDatabaseC1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1ee): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: collect2.exe: error: ld returned 1 exit status
:-1: error: ninja: build stopped: subcommand failed. -
@thecodemonkey now when I include the QSqlDatabase header file these errors occures: :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x3b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x8b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0xef): undefined reference to__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x14f): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1a9): undefined reference to__imp__ZN12QSqlDatabaseC1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1ee): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: collect2.exe: error: ld returned 1 exit status
:-1: error: ninja: build stopped: subcommand failed.wrote on 1 Jul 2023, 07:25 last edited by@cpplegend Did you link the Sql module in CMakeLists ?
-
@thecodemonkey now when I include the QSqlDatabase header file these errors occures: :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x3b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x8b): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0xef): undefined reference to__imp__ZN12QSqlDatabaseD1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x14f): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1a9): undefined reference to__imp__ZN12QSqlDatabaseC1Ev' :-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x1ee): undefined reference to
__imp__ZN12QSqlDatabaseD1Ev'
:-1: error: collect2.exe: error: ld returned 1 exit status
:-1: error: ninja: build stopped: subcommand failed.wrote on 1 Jul 2023, 08:39 last edited by JonB 7 Jan 2023, 08:48@cpplegend
If I am not mistaken::-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x3b): undefined reference to __imp__ZN12QSqlDatabaseD1Ev'
widget.cpp.obj
indicates this has been compiled with MSVC (MSVC does.obj
files, MinGW does.o
) and__imp__ZN12QSqlDatabaseD1Ev
leading__imp_
also indicates MSVC rather than MinGW. [Also if you really have a file namedwidget.cpp.obj
somewhere per the error message that is wrong, MSVC should be generatingwidget.obj
fromwidget.cpp
, but that's another matter.]:-1: error: collect2.exe: error: ld returned 1 exit status
collect2
/ld
indicates MinGW linker.(Assuming I am right) You really need to sort out whether you are using MSVC or MinGW once and for all, and make it consistent....
-
@cpplegend
If I am not mistaken::-1: error: CMakeFiles/untitled1.dir/widget.cpp.obj:widget.cpp:(.text+0x3b): undefined reference to __imp__ZN12QSqlDatabaseD1Ev'
widget.cpp.obj
indicates this has been compiled with MSVC (MSVC does.obj
files, MinGW does.o
) and__imp__ZN12QSqlDatabaseD1Ev
leading__imp_
also indicates MSVC rather than MinGW. [Also if you really have a file namedwidget.cpp.obj
somewhere per the error message that is wrong, MSVC should be generatingwidget.obj
fromwidget.cpp
, but that's another matter.]:-1: error: collect2.exe: error: ld returned 1 exit status
collect2
/ld
indicates MinGW linker.(Assuming I am right) You really need to sort out whether you are using MSVC or MinGW once and for all, and make it consistent....
-
@JonB I am using mingw, I know that because its the only package I have installed between mingw and msvc
wrote on 1 Jul 2023, 09:46 last edited by@cpplegend Then what about as @thecodemonkey said?
-
@cpplegend Did you link the Sql module in CMakeLists ?
wrote on 1 Jul 2023, 09:59 last edited by cpplegend 7 Jan 2023, 10:00@thecodemonkey @JonB how do I make it?
-
@thecodemonkey @JonB how do I make it?
wrote on 1 Jul 2023, 17:24 last edited by@cpplegend maybe it gets us further if you post your project here first, incl CMakeLists.txt
69/69