I'm developing an IoT C++ application and I want to send the data over MQTT. Therefore, I created a header-class for my special needs:
#include <mqtt/client.h>
class ClientMQTT{
    public:
        ClientMQTT();
        ClientMQTT(std::string _mqtt_ip_address, int _mqtt_port, std::string _mqtt_username, std::string _mqtt_password, std::string _client_id, bool no_publish);
        int mqtt_send(char *message, int msg_length, std::string topic);
        void report_error(std::string timestamp, std::string message);
        bool connect();
        bool disconnect();
        mqtt::client *client;
        std::string mqtt_ip_address;
        int mqtt_port;
        std::string mqtt_username;
        std::string mqtt_password;
        std::string client_id;
        bool no_publish;
};
For (dis)connecting, i created two functions that I can call when the program starts and exits, bool connect() and bool disconnect(). The body looks like this:
bool ClientMQTT::disconnect(){
    if(this->client == NULL) return true;
    this->client->disconnect();
    return !(this->client->is_connected());  //this makes problems!
}
When disconnecting, I need to check whether the MQTT client really has disconnected or not. So i call the virtual bool mqtt::client::is_connected() function.
The problem is, that I get the following error when compiling/linking: /usr/bin/ld: obj/Debug/CAN_Reader.o||undefined reference to symbol 'MQTTAsync_isConnected'
But I linked the MQTT-Library with -lpaho-mqttpp3, cause without this code line, the program compiles and works ...
Does anybody of you know why this error occurs?
 
     
    