by redboltz

redboltz / mqtt_cpp
168 Stars 63 Forks Last release: 3 months ago (v8.0.0) Boost Software License 1.0 1.0K Commits 29 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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

Version 8.0.0 Actions StatusBuild Statuscodecov

Important note

MQTT v5 is supported since version 4.0.0.


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

Add mqttcpp/include to your include path. Then, include `mqttcpp.hpp

mqttservercpp.hpp` as follows:

For clients: ```c++


include // if you want to use typical logging setup

For servers:
#include  // if you want to use typical logging setup

You can compile your code as follows:

g++ -std=c++14 -Ipath_to_mqtt_cpp/include your_program.cpp -pthread additional_options


|what you want|required option| |---|---| |TLS support|

-DMQTT_USE_TLS -pthread -lssl -lcrypto
| |Logging support|
-DMQTT_USE_LOG -DBOOST_LOG_DYN_LINK -lboost_log -lboost_filesystem -lboost_thread
| |WebSocket support|

You can see more detail at


Usage in cmake project

Add following lines to your

set(LIBNAME "your_project_name")
add_library(${LIBNAME} )

find_package(mqtt_cpp_iface REQUIRED) target_link_libraries(${LIBNAME} LINK_PUBLIC mqtt_cpp_iface::mqtt_cpp_iface)

This uses the

target and includes all necessary link dependencies.


You can build tests and examples as follows:

At mqtt_cpp directory

mkdir build
cd build
cmake ..
make test

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


You can create html documents using doxygen.

make doxygen


mqtt_cpp is licensed under the Boost Software License, Version 1.0. See the

file for details.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.