Skip to content

KurtPattyn/QtMqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QtMqtt

License Linux/OS X Build Status Windows Build Status

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.

Building and installing

Requirements

QtMqtt is created using Qt version 5.
QtMqtt uses CMake to build the sources. The minimum version of CMake is 3.5

Building

#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  
make

Run unit tests

make test

To enable testing of internal code, add -DPRIVATE_TESTS_ENABLED (default: OFF) to the cmake command line.

Installing

make install

This will install the library and the headers to CMAKE_INSTALL_PREFIX.
CMAKE_INSTALL_PREFIX defaults to /usr/local on UNIX/macOS and c:/Program Files on Windows.
To install in another location, add -DCMAKE_INSTALL_PREFIX="<custom location>" to the cmake command line.

Usage

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>

Enabling debug output

To enable debugging information of QtMqtt, the following environment variable can be defined.
QT_LOGGING_RULES="QtMqtt.*.debug=true"

License

MIT