Compiling Paho C Client

1944 views
Skip to first unread message

Satish Madala

unread,
Oct 14, 2015, 1:28:11 PM10/14/15
to MQTT
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 http://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.c.git
cd org.eclipse.paho.mqtt.c.git
make
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. ) 

Thanks!

Jan-Piet Mens

unread,
Oct 14, 2015, 1:56:19 PM10/14/15
to mq...@googlegroups.com
> > */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.

-JP

Satish V Madala

unread,
Oct 14, 2015, 9:54:18 PM10/14/15
to mq...@googlegroups.com
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

)

Thanks!

With Regards,

Satish V Madala Techpreneur & FOSS Evangelist


--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to a topic in the Google Groups "MQTT" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mqtt/wKP6v_bTZ2M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

dadang lukisnyo

unread,
Mar 7, 2016, 6:37:33 AM3/7/16
to MQTT
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
Forward
0 new messages