qt_mysql_driver
qt_mysql_driver copied to clipboard
A detailled way to build it yourself
Hi,
I was wondering f it was possible to give me/us a small step by step tutorial on how to build for Linux and/or Windows? I somehow managed to grasp how to build it in Windows, but it was after following way to much different tutorials on Internet, but since you seem to already master it, f you could share it would be great.
Thanks in advance.
Hi, this can be quite tricky and lots of things can go wrong. I try to describe the steps for Qt 5 on Ubuntu first, Qt 6 has a new build system (CMake), I'll add the steps for that and for Windows respectively later:
Some prerequisites before the actual building process:
- Install the libmysqlclient (if not already pre-installed)
sudo apt install libmysqlclient21 - Install the libmysql development files
sudo apt install libmysqlclient-dev - Install Qt 5 using official installer, select Sources to be installed

- Run the configure script in terminal. Assuming we installed Qt in /opt/Qt/5.12.11:
cd /opt/Qt/5.12.11/Srcsudo ./configure
Then for building:
cd /opt/Qt/5.12.11/Src/qtbase/src/pluginssudo /opt/Qt/5.12.11/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/localcd sqldrivers/mysqlThere should be a Makefile in that folder which was created my the qmake command. check withls
sudo make install- if all went well, we are done, and the .so files are in /opt/Qt/5.12.11/gcc_64/plugins/sqldrivers/

I hope I did't forget anything
Hi, this seem to be exactly what I was looking for, that's great thanks. I will check if I manage to do it in the next 48h to keep you in check. Not as important as making the plugin, but does this work on an Android device? Just for general knowledge, I can't really see any use of a MySql connection on an Android app.
Here I am again, I can't even manage to install QT on my Raspberry. I don't really understand why, but the qt-unified-XXXX.run don't seem to be working even though I have set the file to be executable, so I can't really give you a feedback about the tutorial, even since it seems to be good.
is maybe this library missing:
sudo apt install libxkbcommon-x11-0
? This was the cause for me recently that the Qt installer didn't run at first.
As for Android: I have no experience with Qt on Android, so I don't know at the moment
Hi, any change to get a windows tutorial?
you can make tutorial for qt 6.3 on ubuntu or windows?
Sorry for the long delay, but I couldn't get it to work using cmake on Windows earlier. Anyway, here are 2 batch files for Windows cmd, that might help. You must of course adjust the paths and version numbers accordingly
for MSVC:
Prerequisites:
- Install MSVC Compiler (from Visual Studio 2022 Setup)
- Install Qt incl. Sources, CMake and Ninja from Maintenance Tool
- Install MySQL library, e.g. by using Oracle's Installer or use the zip file from here
set PATH=%PATH%;C:\Qt\Tools\CMake_64\bin;C:\Qt\Tools\Ninja
cd C:\Qt\6.4.0\Src\qtbase\src\plugins\sqldrivers
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
call C:\Qt\6.4.0\msvc2019_64\bin\qt-cmake.bat -G "Ninja" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\msvc2019_64"
ninja
ninja install
call C:\Qt\6.4.0\msvc2019_64\bin\qt-cmake.bat -G "Ninja" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\msvc2019_64" -DCMAKE_BUILD_TYPE=Release
ninja
ninja install
pause
for MinGW:
Prerequisites:
- Install Qt incl. Sources, CMake and MinGW from Maintenance Tool
- Install MySQL library, e.g. by using Oracle's Installer or use the zip file from here
set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
cd C:\Qt\6.4.0\Src\qtbase\src\plugins\sqldrivers
call C:\Qt\6.4.0\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
mingw32-make
mingw32-make install
pause
What can I do to build drivers for android using Qt5 on windows