欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 八卦 > 编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动

编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动

2024/11/30 14:43:35 来源:https://blog.csdn.net/quantum7/article/details/142298654  浏览:    关键词:编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动

找了很多编译博文,都错误。最后找到了正确编译办法:

https://zhuanlan.zhihu.com/p/567883165

  • 直接下载编译好的源码及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 PATH=%PATH%;D:\Qt\Tools\CMake_64\bin;D:\Qt\Tools\Ninja
  • 来到sql驱动源码目录
D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers
  • 命令1
D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers>call "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.11.2
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers\mysql> cd ..D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers>call "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.11.2
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
  • 命令2
D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers>call D:\Qt\6.7.2\msvc2019_64\bin\qt-cmake.bat -G "Ninja" . -DMySQL_INCLUDE_DIR="c:\Program Files\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="c:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="d:\QtTemp\msvc2019_64" -DCMAKE_BUILD_TYPE=Release
-- The CXX compiler identification is MSVC 19.41.34120.0
-- The C compiler identification is MSVC 19.41.34120.0
-- The ASM compiler identification is MSVC
-- Found assembler: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- CMAKE_BUILD_TYPE was already explicitly set to: 'Release'
CMake Error at CMakeLists.txt:52 (add_subdirectory):The source directoryD:/Qt/6.7.2/Src/qtbase/src/plugins/sqldrivers/mysqldoes not contain a CMakeLists.txt file.-- Configuration summary shown below. It has also been written to D:/Qt/6.7.2/Src/qtbase/src/plugins/sqldrivers/config.summary
-- Configure with --log-level=STATUS or higher to increase CMake's message verbosity. The log level does not persist across reconfigurations.-- Configure summary:Qt Sql Drivers:DB2 (IBM) .............................. noInterBase .............................. noMySql .................................. yesOCI (Oracle) ........................... noODBC ................................... yesPostgreSQL ............................. noSQLite ................................. yesUsing system provided SQLite ......... noMimer .................................. no-- Configuring incomplete, errors occurred!
  • 命令3
D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers>ninja
[23/23] Linking CXX shared module plugins\sqldrivers\qsqlite.dll
  • 命令4
D:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers>ninja install
[0/1] Install the project...-- Install configuration: "Release"
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
-- Installing: D:/QtTemp/msvc2019_64/./plugins/sqldrivers/qsqlmysql.dll
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets-release.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginAdditionalTargetInfo.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfig.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersion.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersionImpl.cmake
-- Installing: D:/QtTemp/msvc2019_64/./plugins/sqldrivers/qsqlodbc.dll
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginTargets.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginTargets-release.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginAdditionalTargetInfo.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfig.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersion.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersionImpl.cmake
-- Installing: D:/QtTemp/msvc2019_64/./plugins/sqldrivers/qsqlite.dll
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets-release.cmake
-- Installing: D:/QtTemp/msvc2019_64/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginAdditionalTargetInfo.cmake
  • 检查文件产生

  • 复制到

D:\Qt\6.7.2\mingw_64\plugins\sqldrivers

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com