Author: Kurt Pattyn.
QtMqtt is an implementation of the MQTT protocol for Qt-based projects. It implements version 3.1.1 of the protocol. QtMqtt only depends on Qt libraries.
QtMqtt is created using Qt version 5.
QtMqtt uses CMake to build the sources. The minimum version of CMake is 3.5
#Create a directory to hold the sources.
mkdir qtmqtt
cd qtmqtt
#Check out the sources.
git clone...
#Create build directory
mkdir build
#Go into the build directory
cd build
#Create the build files
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=OFF ..
#To make a release build, change `-DCMAKE_BUILD_TYPE=debug` to `-DCMAKE_BUILD_TYPE=release`
#To make a dynamic library, change `-DBUILD_SHARED_LIBS=OFF` to `-DBUILD_SHARED_LIBS=ON`
#Build the library
makemake test
To enable testing of internal code, add
-DPRIVATE_TESTS_ENABLED(default: OFF) to thecmakecommand line.
make install
This will install the library and the headers to
CMAKE_INSTALL_PREFIX.
CMAKE_INSTALL_PREFIXdefaults to/usr/localon UNIX/macOS andc:/Program Fileson Windows.
To install in another location, add-DCMAKE_INSTALL_PREFIX="<custom location>"to thecmakecommand line.
Include the following in your CMakeLists.txt file
find_package(Qt5Core)
find_package(Qt5NetWork)
find_package(Qt5WebSockets)
find_package(Qt5Mqtt)
target_link_libraries(<target> Qt5::Mqtt)In your C++ source file include the QtMqtt module
#include <QtMqtt>To enable debugging information of QtMqtt, the following environment variable can be defined.
QT_LOGGING_RULES="QtMqtt.*.debug=true"