当前位置: 首页 > news >正文

ubuntu下Qt5自动编译配置QtMqtt环境(10)

文章目录

    • @[toc]
    • 1、概述
    • 2、下载QtMqtt源码
    • 3、编译
    • 4、验证
    • 5、参考
    • 6、视频

更多精彩内容
👉内容导航 👈
👉Qt网络编程 👈

1、概述

  • Qt默认是不包含mqtt库的,如果需要使用到mqtt库就只能自己编译配置;

  • 网络所有的QtMqtt配置的文章都是编译完成手动复制,非常麻烦,对新手也非常不友好吗,容易漏了一些步骤;

  • 本文中主要说明如何自动编译配置QtMqtt,无需手动拷贝、生成帮助手册
    注意: 编译前需要安装sudo apt install perl,如果没有perl则编译后生成的头文件都是带.h后缀的。

演示环境:

环境版本
相同ubuntu22.04
Qt5.14.2
QtMqtt5.14.2

2、下载QtMqtt源码

  • 命令行下载:下载完成后选择QtMqtt版本,与Qt版本相同或者相近;
git clone https://github.com/qt/qtmqtt.git
git clone http://code.qt.io/qt/qtmqtt.git
git clone https://code.qt.io/qt/qtmqtt.gitgit tag   # 查看分支
git checkout 5.14.2  # 切换分支
  • 浏览器下载:

在这里插入图片描述

3、编译

  • 使用qtcreator打开qtmqtt.pro(qtcreator如果不是使用sudo权限运行,则下面的2、3步需要自己打开终端运行命令行)
  • 添加编译配置;
    • 选择【项目】【构建】【添加构建步骤】【make】;
    • 第一个:在make参数项添加docs,用于生成帮助手册;
    • 第二个:在make参数项添加install_docs,用于自动安装帮助手册;(需要管理员权限)
    • 第三个:在make参数项添加install,用于自动安装编译好的qtmqtt;(需要管理员权限)

在这里插入图片描述

在这里插入图片描述

  • 编译报错:是因为使用make install_docs安装没有权限
19:57:10: 正在启动 "/usr/bin/make" install_docs -j16cd src/ && ( test -e Makefile || /opt/Qt5.14.2/5.14.2/gcc_64/bin/qmake -o Makefile /home/mhf/qtmqtt/src/src.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug ) && /usr/bin/make -f Makefile install_docs
make[1]: Entering directory '/home/mhf/qtmqtt/build/gcc64-Debug/src'
cd mqtt/ && ( test -e Makefile || /opt/Qt5.14.2/5.14.2/gcc_64/bin/qmake -o Makefile /home/mhf/qtmqtt/src/mqtt/mqtt.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug ) && /usr/bin/make -f Makefile install_docs
make[2]: Entering directory '/home/mhf/qtmqtt/build/gcc64-Debug/src/mqtt'
/opt/Qt5.14.2/5.14.2/gcc_64/bin/qmake -install qinstall /home/mhf/qtmqtt/build/gcc64-Debug/doc/qtmqtt /opt/Qt5.14.2/Docs/Qt-5.14.2/qtmqtt
/opt/Qt5.14.2/5.14.2/gcc_64/bin/qmake -install qinstall /home/mhf/qtmqtt/build/gcc64-Debug/doc/qtmqtt.qch /opt/Qt5.14.2/Docs/Qt-5.14.2/qtmqtt.qch
Error copying /home/mhf/qtmqtt/build/gcc64-Debug/doc/qtmqtt.qch to /opt/Qt5.14.2/Docs/Qt-5.14.2/qtmqtt.qch: Destination file exists
Error copying /home/mhf/qtmqtt/build/gcc64-Debug/doc/qtmqtt/examples-manifest.xml to /opt/Qt5.14.2/Docs/Qt-5.14.2/qtmqtt/examples-manifest.xml: Destination file exists
make[2]: *** [Makefile:2947: install_inst_qch_docs] Error 3
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/mhf/qtmqtt/build/gcc64-Debug/src/mqtt'
make[2]: *** [Makefile:2938: install_inst_html_docs] Error 3
make[1]: Leaving directory '/home/mhf/qtmqtt/build/gcc64-Debug/src'
make[1]: *** [Makefile:540: sub-mqtt-install_docs] Error 2
make: *** [Makefile:597: sub-src-install_docs] Error 2
19:57:11: 进程"/usr/bin/make"退出,退出代码 2 。
Error while building/deploying project qtmqtt (kit: gcc64)
When executing step "Make"
  • 打开终端,进入编译路径下,再使用sudo make installsudo make install_docs进行安装。

在这里插入图片描述

4、验证

  • 将qtmqtt\examples\mqtt路径下的示例工程复制 出来,使用qtcreator打开进行编译。
  • 如果不复制到qtmqtt工程外,可能无法编译。

在这里插入图片描述

  • 编译成功后如下所示:

在这里插入图片描述

  • 使用qtmqtt只需要在pro文件中添加QT += mqtt就可以引入。

在这里插入图片描述

5、参考

  • qt/qtmqtt.git - Qt Module to implement MQTT protocol version 3.1 and 3.1.1 http://mqtt.org/
  • GitHub - qt/qtmqtt: Qt Module to implement MQTT protocol version 3.1 and 3.1.1 http://mqtt.org/

6、视频

linux下qt5全自动编译配置qtmqtt



http://www.lryc.cn/news/499334.html

相关文章:

  • Vulnhub DC-3靶机攻击实战(一)
  • 常用传感器介绍合集
  • “为您的家电穿上防震铠甲:优质电器缓冲器
  • Elasticsearch入门之HTTP高级查询操作
  • Java基础-异常
  • 鲲鹏麒麟使用Docker部署Redis5
  • 家政项目小程序+ssm
  • Day7 苍穹外卖项目 缓存菜品、SpringCache框架、缓存套餐、添加购物车、查看购物车、清空购物车
  • 天天 AI-241207:今日热点- Windsurf:在工程能力上进一步进化的Cursor
  • Windows远程桌面连接到Linux
  • 使用前,后端写 具有分页效果的数据展示
  • ubuntu防火墙管理(六)——ebtables
  • Oracle开发和应用——常用对象(表)
  • 嵌入式蓝桥杯学习8 模拟电压测量
  • FFmpeg源码中,计算CRC校验的实现
  • Android笔记【14】结合LaunchedEffect实现计时器功能。
  • kubectl 和 kubeconfig 基本原理
  • LVGL笔录----动画
  • 【LeetCode热题100】BFS解决FloodFill算法
  • 设计模式の软件设计原则
  • Linux centos7 下载MySQL5.7仓库的命令
  • CSS flex布局踩坑小记:flex-basis属性之0px与0%的差异 (赞)
  • 华硕主板不能开启
  • 室联人形机器人:家政服务任务结构化、技术要点、深入应用FPGA的控制系统框架设计(整合版)
  • OpenAI 发布 o1 LLM,推出 ChatGPT Pro
  • 【MySQL】存储过程和触发器
  • QT4和 QT5 槽函数连接的区别
  • 使用 PyTorch 和 Horovod 来编写一个简单的分布式训练 demo
  • SQL复杂查询功能介绍及示例
  • shell基础用法