[Qt] Qt5.12 compiled MySQl5.7 drive (personally tested successfully)

00. Contents

01. Installation Qt5.12

Qt5.12 choice when installing Qt compiler and Qt source code

02. MySQL open source projects

Qt5.12 installation directory is as follows

Qt\Qt5.12.2\5.12.2\Src\qtbase\src\plugins\sqldrivers\mysql

03. compile MySQL driver code

Code structure:

Direct compile error: database driver is not defined

Analysis: Because no path is specified MySQL dynamic library

04. Modify mysql.pro file

After modifications are as follows:

TARGET = qsqlmysql

HEADERS += $$PWD/qsql_mysql_p.h
SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp

#QMAKE_USE += mysql

OTHER_FILES += mysql.json

PLUGIN_CLASS_NAME = QMYSQLDriverPlugin

win32:LIBS += -LD:/mysql-5.7.23-winx64/lib/ -llibmysql
INCLUDEPATH += D:/mysql-5.7.23-winx64/include
DEPENDPATH += D:/mysql-5.7.23-winx64/include


include(../qsqldriverbase.pri)

The new additions are as follows:

05. After compiling obtain corresponding library

My Qt installation path: H: \ Qt \ Qt5.12.2

Resulting disk drive directory in H

The qsqlmysql.dll qsqlmysqld.dll and copied to the install directory Qt H: \ Qt \ Qt5.12.2 \ 5.12.2 \ mingw73_64 \ plugins \ sqldrivers

06. dynamic library copy to the specified directory

DLL Download:
https://download.csdn.net/download/dengjin20104042056/11260174
or

Links: https://pan.baidu.com/s/1EPiKhDLKCMYkO-GhN8xX3A
extraction code: kpt0

After downloading libmysql.dll copied to the installation directory of Qt

07. Test results

Reference blog: https://blog.csdn.net/dengjin20104042056/article/details/94129925

If the blog solves the problem of your work, you can play with a micro-channel 0.99 yuan appreciation, thank you!

Guess you like

Origin www.cnblogs.com/szitcast/p/11105899.html