Compiling Paho C Client

Skip to first unread message

Satish Madala

Oct 14, 2015, 1:28:11 PM10/14/15
Hi folks!

I have been using MQTT since many days and for the first time i have to use a C/C++ Client. Probably, there is a compiling problem with the present code at paho git (or i miss something):

git clone
cd org.eclipse.paho.mqtt.c.git
make install
Make Install was succesful and I have tried the sample in src directory.

gcc pubsync.c 
/tmp/ccbSD877.o: In function `main':
pubsync.c:(.text+0xf2): undefined reference to `MQTTClient_create'
pubsync.c:(.text+0x116): undefined reference to `MQTTClient_connect'
pubsync.c:(.text+0x191): undefined reference to `MQTTClient_publishMessage'
pubsync.c:(.text+0x1d1): undefined reference to `MQTTClient_waitForCompletion'
pubsync.c:(.text+0x202): undefined reference to `MQTTClient_disconnect'
pubsync.c:(.text+0x211): undefined reference to `MQTTClient_destroy'
collect2: error: ld returned 1 exit status
I got these errors. Any compilation document would be really helpful.

Am running 15.04 Ubuntu. Was running mosquitto_clients and python clients on the machine.
(Actually, I want C++ implementation, which would require this C Client installed. ) 


Jan-Piet Mens

Oct 14, 2015, 1:56:19 PM10/14/15
> > */tmp/ccbSD877.o: In function `main':*
> > *pubsync.c:(.text+0xf2): undefined reference to `MQTTClient_create'*

That looks like you're not linking with the library. In case of doubt
check the Paho mailing list.


Satish V Madala

Oct 14, 2015, 9:54:18 PM10/14/15
Hi Jan,

Yes. It looks like library isn't linked! If header files are not there, compiler throws and exception that no such file was found. But all the headers files were loading.

Few starting lines of the program:

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "MQTTClient.h"
How do link the libraries while compiling the pubsync.c file? 

(In C++, I tried src-Make, which also says: 
/usr/bin/ld: cannot find -lmqttpp
/usr/bin/ld: cannot find -lmqttv3a



With Regards,

Satish V Madala Techpreneur & FOSS Evangelist

To learn more about MQTT please visit
You received this message because you are subscribed to a topic in the Google Groups "MQTT" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

dadang lukisnyo

Mar 7, 2016, 6:37:33 AM3/7/16
Hi Satish Mandala,
You can find library name from the Makefile in directory "org.eclipse.paho.mqtt.c.git".

# The names of the four different libraries to be built
MQTTLIB_C = paho-mqtt3c
MQTTLIB_CS = paho-mqtt3cs
MQTTLIB_A = paho-mqtt3a
MQTTLIB_AS = paho-mqtt3as 

To build pubsync.c:

gcc pubsync.c -o pubsync -lpaho-mqtt3c

Reply all
Reply to author
0 new messages