Getting QSqlError "Driver not loaded"
-
You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
-
You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
@Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":
You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
I did see that and I'd [mis]understood it as saying DLLs were now being supplied.
So, looking at this bit of info:
mkdir build-sqldrivers cd build-sqldrivers qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_ROOT="C:\mysql-8.0.22-winx64" cmake --build . cmake --install .I have some questions about that.
These two lines:
mkdir build-sqldrivers cd build-sqldriversWhat directory are these new subdirectories to be put? Or does it not matter?
qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_ROOT="C:\mysql-8.0.22-winx64"This <qt_installation_path> I am assuming is where that particular release of Qt lives. So in my case this is
c:\Qt6\6.10.2
However, that does not have a source directory. So, do I have to download the Qt source here first?
qt_installation_path>\<platform>What is platform here?
DMySQL_ROOT="C:\mysql-8.0.22-winx64Is this, for me:
C:\Program Files\MariaDB\MariaDB Connector C 64-bit
Where I have subdirectories:
lib which has mariadb.dll
And:
include which has mysql.h
And at the end of this, what will it actually create in terms of a DLL? Something like QMAriadb.dll or QMysql.dll and it's basically jiust a wrapper for the already supplied mariadb.dll?
Thanks.
-
Hi,
You can put the build wherever you want outside of Qt's sources.
The
<qt_installation_path>is the root where you have Qt. In your case it seems to beC:/Qt6.You have to download the Qt sources that matches the version you want to build the driver for. You can do that through the Maintenance Tool.
platformis what you have afterC:/Qt6/6.10.2It will create a plugin that will use the library you supplied.
-
OK, thanks to everyone, I now have it compiled and running. It fought me. A lot.
I had to install cmake, then ninja, then reboot. Then eventually worked out that I was trying to use Mingw parts with MSVC compiler, so rebuilt against Qt using Mingw as the compiler and it eventually worked.
Uff, it's always easier on Linux! :D
Why do you have to compile on Windows when on Linux this just works? None of this having to build libraries stuff!
-
OK, thanks to everyone, I now have it compiled and running. It fought me. A lot.
I had to install cmake, then ninja, then reboot. Then eventually worked out that I was trying to use Mingw parts with MSVC compiler, so rebuilt against Qt using Mingw as the compiler and it eventually worked.
Uff, it's always easier on Linux! :D
Why do you have to compile on Windows when on Linux this just works? None of this having to build libraries stuff!
@DiBosco said in Getting QSqlError "Driver not loaded":
Why do you have to compile on Windows when on Linux this just works?
You have to build the Qt sql driver for MySQL by yourself for legal reasons
And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.
-
I use for PostgreSQL, maybe help you
set(POSTGRESQL_DLL_DIR "C:/Program Files/PostgreSQL/17/bin") foreach(dll IN ITEMS libpq.dll libssl-3-x64.dll libcrypto-3-x64.dll libiconv-2.dll libintl-9.dll libpgtypes.dll libwinpthread-1.dll libxml2.dll libxslt.dll libzstd.dll libcurl.dll libecpg.dll libecpg_compat.dll liblz4.dll ) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${POSTGRESQL_DLL_DIR}/${dll}" $<TARGET_FILE_DIR:${PROJECT_NAME}> ) endforeach() -
@DiBosco said in Getting QSqlError "Driver not loaded":
Why do you have to compile on Windows when on Linux this just works?
You have to build the Qt sql driver for MySQL by yourself for legal reasons
And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.
@Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":
@DiBosco said in Getting QSqlError "Driver not loaded":
Why do you have to compile on Windows when on Linux this just works?
You have to build the Qt sql driver for MySQL by yourself for legal reasons
And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.
I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?
-
@Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":
@DiBosco said in Getting QSqlError "Driver not loaded":
Why do you have to compile on Windows when on Linux this just works?
You have to build the Qt sql driver for MySQL by yourself for legal reasons
And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.
I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?
@DiBosco I think it's likely just a miscomprehension.
We had many people trying to build the whole of Qt in place of just building the plugins they needed following the documentation.
From the looks of it, you followed the right path but just had an issue with the compiler setup.
-
@Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":
@DiBosco said in Getting QSqlError "Driver not loaded":
Why do you have to compile on Windows when on Linux this just works?
You have to build the Qt sql driver for MySQL by yourself for legal reasons
And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.
I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?
@DiBosco said in Getting QSqlError "Driver not loaded":
just the mariadb libs.
Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.
-
@DiBosco said in Getting QSqlError "Driver not loaded":
just the mariadb libs.
Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.
@Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":
@DiBosco said in Getting QSqlError "Driver not loaded":
just the mariadb libs.
Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.
Yep, that's all I did. Sounds like I described it poorly.
Am still intruiged as to why this has to be done on Windows, but not on Linux (or at least my Linux distro).
-
D DiBosco has marked this topic as solved