编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动(MinGW版)
- 参考
GitHub - thecodemonkey86/qt_mysql_driver: Typical symptom: QMYSQL driver not loaded. Solution: get pre-built Qt SQL driver plug-in required to establish a connection to MySQL / MariaDB using Qt. Download qsqlmysql.dll binaries built from official Qt source code
- 或者直接下载:
https://download.csdn.net/download/quantum7/89766162
- 安装VS Virsual Studio 2022 Community
- 安装MySQL
C:\Program Files\MySQL\MySQL Server 8.0
- 安装QT
D:\Qt
要选中三项:
MSVC_2019 64-bit
MinGW 11.2.0 64 bit
Sources
- 编译脚本
注意自己的安装目录。
SET MYSQL_DIR="C:\Program Files\MySQL\MySQL Server 8.0"
SET QT_DIR=D:\Qt
set PATH=%PATH%;%QT_DIR%\Tools\mingw1120_64\bin;%QT_DIR%\Tools\CMake_64\bin
SET QT_VERSION_DIR=D:\Qt\6.7.2
SET SQLDRIVERS_DIR=%QT_VERSION_DIR%\Src\qtbase\src\plugins\sqldrivers
cd %SQLDRIVERS_DIR%
SET QT_MINGW_DIR=%QT_VERSION_DIR%\mingw_64
call %QT_MINGW_DIR%\bin\qt-cmake.bat ^
-G "MinGW Makefiles" . ^
-DMySQL_INCLUDE_DIR=%MYSQL_DIR%\include ^
-DMySQL_LIBRARY=%MYSQL_DIR%\lib\libmysql.lib ^
-DCMAKE_INSTALL_PREFIX="%QT_MINGW_DIR%" ^
-DCMAKE_C_COMPILER="gcc.exe" ^
-DCMAKE_CXX_COMPILER="g++.exe"
mingw32-make
mingw32-make install
pause
- 检查文件
D:\Qt\6.7.2\mingw_64\plugins\sqldrivers