-
Download MySql C Connector v6.1.
Download the MySql Installer from:
https://dev.mysql.com/downloads/installer/
Install C Connector 6.1 (Note the location we will need it later) -
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.
-
Building Plugin
- 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) )
- cd to sqldrivers path in qt source
cd D:\\QT\\Qt5.13.1\\5.13.1\\Src\\qtbase\\src\\plugins\\sqldrivers
- Run qmake here.
qmake sqldrivers.pro
(to create qtsqldrivers-config.pri ) - cd to mysql.
cd D:\\QT\\Qt5.13.1\\5.13.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\mysql
- Run qmake here. qmake mysql.pro
-
Add the plugin to the list
Once successfully build you will find qsqlmysql.dll and qsqlmysqld.dll in
the following location
D:\QT\Qt5.13.1\5.13.1\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
Copy both qsqlmysql.dll and qsqlmysqld.dll and place them in the compiler’s
plugin directory
D:\QT\Qt5.13.1\5.13.1\mingw73_32\plugins\sqldrivers
Error in Building?
-
Library 'mysql' is not defined.
In file cd
D:\QT\Qt5.13.1\5.13.1\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro
Commend the line
QMAKE_USE += mysql
-
Adding Library path and Include path.
Add the following to mysql.pro at end
LIBS += -L'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/lib/' -llibmysql INCLUDEPATH += 'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/include' DEPENDPATH += 'C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/include'
-
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
Top comments (0)