Need help installing paho.mqtt.c on my raspberry pi

790 views
Skip to first unread message

Anton Gustafsson

unread,
Dec 10, 2017, 1:56:49 PM12/10/17
to MQTT
I have an C application on my raspberry pi running Rasbian that needs to publish to a mqtt broker. Now I found this library and wanted to use it. 
I cloned the repository and then ran make and sudo make install and the installation seems to have worked. If I include the header in my C file and compile; #include "MQTTClient.h" it will compile without any problems. Then I added some sample code and compiled again. This time I get a couple of errors sating undefined reference to various methods that should be located in MQTTClient.C  So it seems to me that the linker somehow does find the h file but not the C file. I'm sorry if this is a stupid question, its just that I've been sitting with this for 2 hours now, unable to make it work. 

Frank Pagliughi

unread,
Dec 10, 2017, 4:28:33 PM12/10/17
to mq...@googlegroups.com, Anton Gustafsson
Try updating the loader cache. Run:
$ sudo ldconfig
Then try to build/link your sample apps again.

Frank


On 12/10/2017 01:56 PM, Anton Gustafsson wrote:
I have an C application on my raspberry pi running Rasbian that needs to publish to a mqtt broker. Now I found this library and wanted to use it. 
I cloned the repository and then ran make and sudo make install and the installation seems to have worked. If I include the header in my C file and compile; #include "MQTTClient.h" it will compile without any problems. Then I added some sample code and compiled again. This time I get a couple of errors sating undefined reference to various methods that should be located in MQTTClient.C  So it seems to me that the linker somehow does find the h file but not the C file. I'm sorry if this is a stupid question, its just that I've been sitting with this for 2 hours now, unable to make it work. 
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Anton Gustafsson

unread,
Dec 10, 2017, 4:48:02 PM12/10/17
to MQTT
Sadly, it seems like I still get the errors:

Anton Gustafsson

unread,
Dec 10, 2017, 4:53:49 PM12/10/17
to MQTT
Think I finally solved it, had to add the library to the compilcation command:  -l paho-mqtt3c
Shouldnt there be a better way though?

Frank Pagliughi

unread,
Dec 10, 2017, 5:03:57 PM12/10/17
to mq...@googlegroups.com, Anton Gustafsson
Oh, yes. You need to link with one of the Paho C libraries. There are four of them: async or sync, with or with out SSL/TLS. It appears that you're using the synchronous library, so try adding:
-lpaho-mqtt3c
to your compile command. If you're using SSL, use the paho-mqtt3cs library instead.

Frank
Reply all
Reply to author
Forward
0 new messages