Skip to content

Instantly share code, notes, and snippets.

@emha69
Created December 1, 2021 10:07
Show Gist options
  • Save emha69/870a99ba7851616bc39b539ac9f533f0 to your computer and use it in GitHub Desktop.
Save emha69/870a99ba7851616bc39b539ac9f533f0 to your computer and use it in GitHub Desktop.
Compiling Qt 5.15 MariaDB SQL plugin on Ubuntu
Step 1: Install MariaDB3 C connector and development package
Step 2: Install QtBase5 private development package
Step 3: Download Qt sources
Step 4: Run configure in QTDIR/Src/qtbase
Step 5: Run qmake in QTDIR/Src/qtbase/src/plugins/sqldrivers
Step 6. Run make
Step 7. Run make install
@emha69
Copy link
Author

emha69 commented Dec 1, 2021

Step 1: Install MariaDB3

apt-get install mariadb3 libmariadb-dev

Step 2: Install Qt private development package

apt-get install qtbase5-private-dev

Step 3: Download Qt Sources

Start maintenance tool and download the Qt sources

Step 4: Run configure

export QTDIR = <path to your installation> e.g. /home/myself/Qt/5.15.2
cd QTDIR/Src/qtbase
./configure -sql-mysql MYSQL_INCDIR="/usr/include/mariadb" MYSQL_LIBDIR="/usr/lib/x86_64-linux-gnu"

Step 5 & 6: Run QMake

Fist run the QMake for sqldrivers, IMPORTANT make sure you run the QMake from Qt and not Linux distribution!

cd QTDIR/Src/qtbase/src/plugins/sqldrivers
QTDIR/gcc_64/bin/qmake sqldrivers.pro
cd QTDIR/Src/qtbase/src/plugins/sqldrivers/mysql
QTDIR/gcc_64/bin/qmake mysql.pro

STEP 6 & 7 Run make

It is wise to start with clean compile but not necessary
make clean
make
sudo make install

This will install the driver in plugins directory QTDIR/gcc_64/plugins/sqldrivers/
To check the plugin use QT_DEBUG_PLUGINS set in environmental variables of Debug configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment