My goal
... is to use the sample code async_subscribe.cpp from the PahoMqttCpp project (https://github.com/eclipse/paho.mqtt.cpp) as a standalone application to then modify it for my needs.
My approach
Preliminaries
On the newest model of Raspberry pi (uname -a--> 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux) I have followed the description in the PahoMqttCpp README.md file. I compiled successfully the C-library (v1.2.1) and then compiled successfuly the Cpp part, finally installed both libraries to /usr/local/lib. During this process, no errors occurred.
My project
Then, as a start for my own project, I copied the async_subscribe.cpp from the PahoMqttCpp samples into a empty directory and started to build a CMakeLists.txt to compile it. Naively, I started with this version:
cmake_minimum_required(VERSION 3.5)
add_library(PahoMqttC SHARED IMPORTED)
set_target_properties(PahoMqttC PROPERTIES IMPORTED_LOCATION /usr/share/lib/libpaho-mqtt3a.so)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PahoMqttCpp REQUIRED)
add_executable(async_subscribe async_subscribe.cpp)
include_directories(${PahoMqttCpp_INCLUDE_DIRS})
target_link_libraries(async_subscribe ${PahoMqttCpp_LIBRARIES})
target_link_libraries(async_subscribe ${PahoMqttC_LIBRARIES})
install(TARGETS async_subscribe RUNTIME DESTINATION bin)
The following cmake -Bbuild -H. command showed no errors, the output was
pi@homepi:~/Develop/CppMosquitto/example $ cmake -Bbuild -H.
-- The C compiler identification