安装qt 6.6.2的mqtt还是官方的吧,能很好融入进开发系统中,直接调用,一直很好用,下面把折磨人的安装方法分享一下,之所以说折磨人,主要是qt 6以后的插件安装采用cmake,原来一直用qmake开发的,不大好上手。
一 *载下**地址
参考上篇博客,选中6.6.2版本*载下**就行
二 打开工程直接报错
报错如下:
E:\Qt\Tools\CMake_64\share\cmake-3.24\Modules\CMakeTestCXXCompiler.cmake:62: error: The C++ compiler "d:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl*ex.e**" is not able to compile a simple test program. It fails with the following output: Change Dir: E:/mywork/programme/TEST/build-untitled01-Desktop_Qt_6_6_2_MSVC2019_64bit-Release/CMakeFiles/CMakeTmp Run Build Command(s):D:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja*ex.e** cmTC_e19da && [1/2] Building CXX object CMakeFiles\cmTC_e19da.dir\testCXXCompiler.cxx.obj [2/2] Linking CXX executable cmTC_e19da*ex.e** FAILED: cmTC_e19da*ex.e** cmd*ex.e** /C "cd . && E:\Qt\Tools\CMake_64\bin\cmake*ex.e** -E vs_link_exe --intdir=CMakeFiles\cmTC_e19da.dir --rc=Ninja --mt="D:\Windows Kits\10\bin\10.0.20348.0\x64\mt*ex.e**" --manifests -- "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64\link*ex.e**" /nologo CMakeFiles\cmTC_e19da.dir\testCXXCompiler.cxx.obj /out:cmTC_e19da*ex.e** /implib:cmTC_e19da.lib /pdb:cmTC_e19da.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." RC Pass 1: command "Ninja /fo CMakeFiles\cmTC_e19da.dir/manifest.res CMakeFiles\cmTC_e19da.dir/manifest.rc" failed (exit code 1) with the following output: ninja: error: unknown target '/fo', did you mean 'all'? ninja: build stopped: subcommand failed.
------------------------------------------------------------------------------------------------------------------------
实际就是没有安装好编译器,等诸多配置环境
打开项目,编译配置一下:

添加一句话:
Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/lib*ex.e**
然后重新配置一下:

可以编译了,最后得到如下结果:

三 安装与测试
把上面这些文件夹的内容,分别复制到qt对应安装目录中,直接可以使用了;

如上面所示,用qt自己的例子,测试成功!