Build Qt MySQL driver


The DB2, Oracle and TDS client drivers are not distributed with the Qt Open Source Editions, because the client libraries are distributed under a license which is not compatible with the GPL license. I don't know since when the MySQL driver for Qt is not equipped in the distribution. So we have to compile the qsqlmysql.dll file ourselves.

Download MySQL installer to install MySQL Connector C 

Download Qt Source code 

cd C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers
qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"

If MySQL is not found, checking config.log under the current folder is very useful for finding out the problem

nmake
namke install

The built dlls will be under C:\Qt\Qt5.12.5\5.12.5\msvc2017_64\plugins\sqldrivers

Copy the dll under your application folder\sqldrivers

Run the application


Last Article

Comment 评论



Share 分享

New Users 最新加入

  • hokurikustr

  • refrain

New comments 最新评论

test123: aasdas Details Apr 13 16:39
admin: Thanks! Details Apr 09 11:46
admin: Google map api Details Apr 09 11:46
lqj12: cooooooooool Details Apr 08 21:34
Yunhan Huang: 这个功能是如何实现的? Details Apr 08 13:23