mqtt_cpp

基于 Boost.Asio 的 C++14 MQTT 客户端/服务器。「MQTT client/server for C++14 based on Boost.Asio」

  • Owner: redboltz/mqtt_cpp
  • Platform: Windows,Linux
  • License:: Boost Software License 1.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

MQTT client/server for C++14 based on Boost.Asio

Version 8.0.0 Actions StatusBuild Statuscodecov

Important note https://github.com/redboltz/mqtt_cpp/wiki/News.

MQTT v5 is supported since version 4.0.0.

Overview

mqtt_cpp is a header only library. It requires C++14 and the Boost Libraries 1.66.0 or later.

Add mqtt_cpp/include to your include path. Then, include mqtt_cpp.hpp and/or mqtt_server_cpp.hpp as follows:

For clients:

#include <mqtt_client_cpp.hpp>

For servers:

#include <mqtt_server_cpp.hpp>

You can compile your program as follows:

g++ -std=c++14 -Ipath_to_mqtt_cpp/include no_tls.cpp -lboost_system -lpthread
g++ -std=c++14 -Ipath_to_mqtt_cpp/include tls.cpp -lboost_system -lssl -lcrypto -lpthread

WebSocket support

If you want to use MQTT on WebSocket, you need to define MQTT_USE_WS macro. mqtt_cpp uses https://github.com/boostorg/beast for WebSocket communication and it requires boost::string_view, so the boost library need to support boost::string_view.

Example

Test

You can build tests and examples as follows:

At mqtt_cpp directory

mkdir build
cd build
cmake ..
make
make test

In order to build tests, you need to prepare the Boost Libraries 1.59.0.

Documents

https://github.com/redboltz/mqtt_cpp/wiki

You can create html documents using doxygen.

make doxygen

License

mqtt_cpp is licensed under the Boost Software License, Version 1.0. See
the LICENSE_1_0.txt file for details.

Main metrics

Overview
Name With Ownerredboltz/mqtt_cpp
Primary LanguageC++
Program languageCMake (Language Count: 4)
Platform
License:Boost Software License 1.0
所有者活动
Created At2015-12-06 12:43:23
Pushed At2025-07-22 13:23:31
Last Commit At2025-07-22 22:22:28
Release Count40
Last Release Namev13.2.2 (Posted on )
First Release Namev1.0.0 (Posted on )
用户参与
Stargazers Count460
Watchers Count21
Fork Count112
Commits Count1.6k
Has Issues Enabled
Issues Count296
Issue Open Count45
Pull Requests Count612
Pull Requests Open Count6
Pull Requests Close Count87
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private