qt_mysql_driver icon indicating copy to clipboard operation
qt_mysql_driver copied to clipboard

A detailled way to build it yourself

Open ArrayIndexOutOfBound opened this issue 4 years ago • 8 comments

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.

ArrayIndexOutOfBound avatar May 31 '21 15:05 ArrayIndexOutOfBound

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:

  1. Install the libmysqlclient (if not already pre-installed) sudo apt install libmysqlclient21
  2. Install the libmysql development files sudo apt install libmysqlclient-dev
  3. Install Qt 5 using official installer, select Sources to be installed image
  4. Run the configure script in terminal. Assuming we installed Qt in /opt/Qt/5.12.11: cd /opt/Qt/5.12.11/Src sudo ./configure

Then for building:

  1. cd /opt/Qt/5.12.11/Src/qtbase/src/plugins
  2. sudo /opt/Qt/5.12.11/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/local
  3. cd sqldrivers/mysql There should be a Makefile in that folder which was created my the qmake command. check with ls image
  4. sudo make install
  5. if all went well, we are done, and the .so files are in /opt/Qt/5.12.11/gcc_64/plugins/sqldrivers/ image

I hope I did't forget anything

thecodemonkey86 avatar Jun 03 '21 17:06 thecodemonkey86

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.

ArrayIndexOutOfBound avatar Jun 03 '21 18:06 ArrayIndexOutOfBound

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.

ArrayIndexOutOfBound avatar Jun 05 '21 19:06 ArrayIndexOutOfBound

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

thecodemonkey86 avatar Jun 08 '21 18:06 thecodemonkey86

Hi, any change to get a windows tutorial?

codewirrwarr avatar Jan 12 '22 06:01 codewirrwarr

you can make tutorial for qt 6.3 on ubuntu or windows?

zaiplanet avatar May 30 '22 04:05 zaiplanet

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:

  1. Install MSVC Compiler (from Visual Studio 2022 Setup)
  2. Install Qt incl. Sources, CMake and Ninja from Maintenance Tool
  3. 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:

  1. Install Qt incl. Sources, CMake and MinGW from Maintenance Tool
  2. 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

thecodemonkey86 avatar Jul 23 '22 17:07 thecodemonkey86

What can I do to build drivers for android using Qt5 on windows

peakoptions avatar Feb 20 '23 13:02 peakoptions