编译mysql for Qt 5.13.0驱动

windows7安装 Qt5.13.0

https://download.qt.io/official_releases/qt/5.13/5.13.0/
下载: qt-opensource-windows-x86-5.13.0.exe,
安装路径:D:\Qt,选择:MinGw32和Src

加入系统路径PATH:
D:\Qt\Qt5.13.0\Tools\mingw730_32\bin;
D:\Qt\Qt5.13.0\Tools\QtCreator\bin;
D:\Qt\Qt5.13.0\5.13.0\mingw73_32\bin

-------------------------------------------------------------------------------

编译mysql for Qt驱动
1.编辑源码:D:\Qt\Qt5.13.0\5.13.0\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro
include(D:\Qt\Qt5.13.0\5.13.0\Src\qtbase\src\plugins\sqldrivers\configure.pri)

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)

win32:LIBS += -LD:\mysql-5.5.39-win32\lib -llibmysql
INCLUDEPATH += D:\mysql-5.5.39-win32\include
DEPENDPATH += D:\mysql-5.5.39-win32\include

构建项目成功

D:\plugins\sqldrivers
libqsqlmysql.a
libqsqlmysqd.a
qsqlmysql.dll
qsqlmysqld.dll

--------------------------------------------------------------------------------

1 把刚刚生成的 qsqlmysql.dll,qsqlmysqld.dll
    拷贝到D:\Qt\Qt5.13.0\5.13.0\mingw73_64\plugins\sqldrivers
2 把Mysql的libmysql.dll文件:D:\mysql-5.5.39-win32\lib\libmysql.dll
    拷贝到D:\Qt\Qt5.13.0\5.13.0\mingw73_64\bin
3 要使用mysql的项目pro文件要加入 QT += sql
    测试成功

转载于:https://www.cnblogs.com/zsfishman/p/11522790.html

你可能感兴趣的:(编译mysql for Qt 5.13.0驱动)