编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动(MSVC版)
相邻你找了很多博文,都没有办法。现在终于找到了正宗。
- 参考
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
- 直接下载编译好的源码及dll文件
https://download.csdn.net/download/quantum7/89760587
- 安装VS Virsual Studio 2022 Community
D:\Program Files\Microsoft Visual Studio\2022\Community
要有VC++/cmake等。
- 安装MySQL
C:\Program Files\MySQL\MySQL Server 8.0
- 安装QT
D:\Qt
要选中三项:
MSVC_2019 64-bit
MinGW 11.2.0 64 bit
Sources
- 编译脚本
注意自己的安装目标。
SET VISUAL_STUDIO_DIR="D:\Program Files\Microsoft Visual Studio"
SET MYSQL_DIR="C:\Program Files\MySQL\MySQL Server 8.0"
SET QT_DIR=D:\Qt
set PATH=%PATH%;%QT_DIR%\Tools\CMake_64\bin;%QT_DIR%\Tools\Tools\Ninja
SET QT_VERSION_DIR=%QT_DIR%\6.7.2
SET SQLDRIVERS_DIR=%QT_VERSION_DIR%\Src\qtbase\src\plugins\sqldrivers
cd %SQLDRIVERS_DIR%
call %VISUAL_STUDIO_DIR%\2022\Community\VC\Auxiliary\Build\vcvars64.bat
SET QT_MSVC_DIR=%QT_VERSION_DIR%\msvc2019_64
call %QT_MSVC_DIR%\bin\qt-cmake.bat ^
-G "Ninja Multi-Config" . ^
-DMySQL_INCLUDE_DIR=%MYSQL_DIR%\include ^
-DMySQL_LIBRARY=%MYSQL_DIR%\lib\libmysql.lib ^
-DCMAKE_INSTALL_PREFIX=%QT_VERSION_DIR%\msvc2019_64 ^
-DCMAKE_CONFIGURATION_TYPES=Release;Debug
ninja
ninja install
pause
- 检查文件产生
- 检查目录
应该是自动复制过来了。
D:\Qt\6.7.2\msvc2019_64\plugins\sqldrivers