How to use the paho mqtt library with a C++ ros node

1k Views Asked by At

I just spend some time trying to figure out how to use the Paho Mqtt library in a C++ Rosnode and write this in case anybody has the same problem.

1

There are 1 best solutions below

1
user2505961 On

Install the Paho library as described in the Github readme.

In the Cmakelists.txt of the Rosnode add:

find_package(PahoMqttCpp REQUIRED)

target_link_libraries(${PROJECT_NAME}
  PahoMqttCpp::paho-mqttpp3
)

in the package.xml add:

  <depend>PahoMqtt</depend>

That should be everything to use it in your C++ code.