自学内容网 自学内容网

编译成功!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


原文地址:https://blog.csdn.net/quantum7/article/details/142330440

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!