DEV Community

Cover image for How I Build a MySql plugin for QT5 (Windows, MinGW32)

How I Build a MySql plugin for QT5 (Windows, MinGW32)

f1r361rd profile image kiran thilak ・2 min read
  1. Download MySql C Connector v6.1.

    Download the MySql Installer from:
    Install C Connector 6.1 (Note the location we will need it later)

  2. Getting QT Source Ready

    To build a plugin for QT u need to get its source. You can install it from Maintenance Tool or manually get it from github repository.

  3. Building Plugin

    1. Open MinGW CMD (Windows -> Start Menu -> Programs -> Qt 5.13.1 -> 5.13.1-> MinGW 7.3.0 (32-bit) -> Qt 5.13.1 (MinGW 7.3.0 32-bit) )
    2. cd to sqldrivers path in qt source
    cd D:\\QT\\Qt5.13.1\\5.13.1\\Src\\qtbase\\src\\plugins\\sqldrivers
    1. Run qmake here. qmake (to create qtsqldrivers-config.pri )
    2. cd to mysql.
    cd D:\\QT\\Qt5.13.1\\5.13.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\mysql
    1. Run qmake here. qmake
  4. Add the plugin to the list

    Once successfully build you will find qsqlmysql.dll and qsqlmysqld.dll in
    the following location

    Copy both qsqlmysql.dll and qsqlmysqld.dll and place them in the compiler’s
    plugin directory

Error in Building?

  1. Library 'mysql' is not defined.

    In file cd

    Commend the line QMAKE_USE += mysql

  2. Adding Library path and Include path.

    Add the following to at end

    LIBS += -L'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/lib/'
    INCLUDEPATH += 'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/include'
    DEPENDPATH += 'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/include'
  3. QSqlDatabase: QMYSQL driver not loaded

    Add the .dll files from C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/lib to D:\QT\Qt5.13.1\5.13.1\mingw73_32\bin

Discussion (0)

Editor guide