我使用的是 QT 版本 6.8.1 并且我也安装了源代码。另外,我正在使用 MySQL Server 8.0 并安装了 MySQL Connector C 6.1 并将 libmysql.dll 文件复制到 C:\Qt .8.1\mingw_64 ,但错误仍然相同。因此,我按照 youtube 上的视频来构建驱动程序cmd 首先设置 PATH 然后使用此命令:
call C:\Qt\6.8.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -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="C:\Qt\6.8.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
但这会导致一些警告和错误。
结果:
-- The CXX compiler identification is GNU 6.3.0
-- The C compiler identification is GNU 6.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/MinGW/bin/gcc.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.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: C:/MinGW/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Warning at C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6ConfigVersion.cmake:56 (message):
Version 6.8.1 of package Qt6 was requested but an incompatible version was
found: 6.8.1 (64bit). You can pass -DQT_NO_PACKAGE_VERSION_CHECK=TRUE to
disable the version check and force the incompatible version to be used.
There is no guarantee the build will succeed. Use at your own risk. You
can silence this warning by passing
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE
Call Stack (most recent call first):
CMakeLists.txt:21 (find_package)
CMake Error at CMakeLists.txt:21 (find_package):
Could not find a configuration file for package "Qt6" that is compatible
with requested version "6.8.1".
The following configuration files were considered but not accepted:
C:/Qt/6.8.1/mingw_64/lib/cmake/Qt6/Qt6Config.cmake, version: 6.8.1 (64bit)
Qt 和插件必须使用相同的编译器构建,
Qt 6.8.1
本身不能使用 Mingw-w64 6.3.0
构建,您至少需要 Mingw-w64 11+
。使用不同主要版本 Mingw-w64
生成的二进制文件不兼容。
如果您使用官方安装程序安装了 Qt 二进制文件,您可能需要
Mingw-w64 13.1
来构建插件。
请参阅支持的平台
操作系统 | 建筑 | 编译器 | 注释 |
---|---|---|---|
Windows 10(1809 或更高版本) | x86_64 | MSVC 2022、MSVC 2019、Mingw-w64 13.1 | |
Windows 11 | x86_64 | MSVC 2022、MSVC 2019、Mingw-w64 13.1 | |
ARM 上的 Windows | ARM64 | MSVC 2019/2022 |
您可以使用
strings
util 识别编译器版本
set PATH=C:\Program Files\Git\usr\bin;C:\MinGW\bin
strings C:\Qt\6.8.1\mingw_64\bin\Qt6Core.dll | grep -i mingw