QT的MYSQL驱动库编译
需要准备QT的源码Src,此次编译64位
在QTCreator中打开mysql.pro
修改两个pro 文件,下图为改好
1.mysql.pro
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
include(../qsqldriverbase.pri)
#下面两个是关于mysql,填自己的mysql路径
INCLUDEPATH +="E:/dev/mysql-8.0.23-winx64/include"
LIBS +="E:/dev/mysql-8.0.23-winx64/lib/libmysql.lib"
#设定编译后生成位置
DESTDIR = ../mysql/lib/
2.qsqldriverbase.pro
QT = core core-private sql-private
# For QMAKE_USE in the parent projects.
#include($$shadowed($$PWD)/qtsqldrivers-config.pri) #注释该行
include(./configure.pri) #修改本行
PLUGIN_TYPE = sqldrivers
load(qt_plugin)
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
点击左下角的小锤子,进行编译,生成lib和dll文件
将三个文件拷贝到D:QT5.14.2mingw73_64pluginssqldrivers
目录下
另外,将mysql的lib目录下libmysql.dll放在
打开QT,新建个工程,记得在pro中加上sql
完成