同步操作将从 aijle/mqtt_cpp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Important note https://github.com/redboltz/mqtt_cpp/wiki/News.
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.67.0 or later.
Add mqtt_cpp/include to your include path. Then, include mqtt_client_cpp.hpp
and/or mqtt_server_cpp.hpp
as follows:
For clients:
#include <mqtt_client_cpp.hpp>
#include <mqtt/setup_log.hpp> // if you want to use typical logging setup
For servers:
#include <mqtt_server_cpp.hpp>
#include <mqtt/setup_log.hpp> // 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
mqtt_cpp uses std::variant or boost::variant internally. If you define the preprocessor macro MQTT_STD_VARIANT then std::variant is chosen, otherwise boost::variant is chosen.
If you use boost::variant, you need to include mqtt/config.hpp prior to the boost headers inclusion becausse it defines boost configuration macros. When you use mqtt_client_cpp.hpp and/or mqtt_server_cpp.hpp, they include mqtt/config.hpp internally.
In include/mqtt/broker
, there are header files to implement mqtt broker.
It is an experimental feature. It would frequently updated. Even if the broker interface would be changed, major version won't be updated.
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 | -DMQTT_USE_WS |
You can see more detail at https://github.com/redboltz/mqtt_cpp/wiki/Config
Add following lines to your CMakeLists.txt
set(LIBNAME "your_project_name")
add_library(${LIBNAME} <your dependencies here>)
find_package(mqtt_cpp_iface REQUIRED)
target_link_libraries(${LIBNAME} LINK_PUBLIC mqtt_cpp_iface::mqtt_cpp_iface)
This uses the mqtt_cpp_iface::mqtt_cpp_iface
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
make test
In order to build tests, you need to prepare the Boost Libraries 1.59.0.
https://github.com/redboltz/mqtt_cpp/wiki
You can create html documents using doxygen.
make doxygen
mqtt_cpp is licensed under the Boost Software License, Version 1.0. See
the LICENSE_1_0.txt
file for details.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。