Compilation error with libmosquitto

Nespressif
Posts: 76
Joined: Tue Sep 12, 2017 11:25 am

Compilation error with libmosquitto

Postby Nespressif » Sat Dec 02, 2017 10:31 am

Hi, Folks,

I'm trying to use the MQTT protocol (so far I've always used REST) with libmosquitto. I have it installed on my system (/usr/include/mosquitto. h) however with #include <mosquitto. h> I get a compilation error "no such directory or file", change to #include </usr/include/mosquitto.h> and compiles but does not find the reference to the defined functions... I get these errors "undefined reference to `mosquitto_lib_init'".

I have uninstalled, cleaned dependencies, cleaned configuration, re-installed and searched for information in forums, but I can't find the solution. I found this clue:
Solved. When using Mosquitto, I had to link the client library in my CMakeList. Basically the libmosquitto. so file, which is the client library.

I added the following to my cmake list:

set (Mosquitto_libs
/usr/lib/x86_64-linux-gnu/libmosquitto. so
/usr/lib/x86_64-linux-gnu/libmosquitto. so. 1
)
target_link_libraries (mqtt_pub_node ${catkin_LIBRARIES} ${Mosquitto_libs})
My goal is to use mqtt to publish and subscribe to Thingspeak, I have already tried mongoose and it doesn't work for me, also tuamtmp and they always gave me rejected connection (error code 5). I've been trying to get mqtt with Thingspeak for a couple of days and I can't make it. It bothers me because with the Arduino IDE it is very easy. I also manage to send the information with the mosquito client from the command line and it goes great.

Please see if anyone can help me solve the libmosquitto compilation error, as I find it a good library with all its documentation.

Greetings and thank you.

Nespressif
Posts: 76
Joined: Tue Sep 12, 2017 11:25 am

Re: Compilation error with libmosquitto

Postby Nespressif » Sat Dec 02, 2017 7:30 pm

I finally made it with Paho.

Who is online

Users browsing this forum: Google [Bot], StanInexeon and 115 guests