Example MQTT Client Code not working C

2020-04-17 04:49发布

I got the example code from here. I have the header file MQTTClient.h as well.

However when I build I get the errors:

undefined reference to MQTTClient_create undefined reference to MQTTClient_connect undefined reference to MQTTClient_publishMessage undefined reference to MQTTClient_waitForCompletion undefined reference to MQTTClient_disconnect

In the header file these are set up as follows:

DLLExport int MQTTClient_create(MQTTClient* handle, const char* serverURI,
    const char* clientId, int persistence_type, void* persistence_context);

I am using a Windows 8 machine with Eclipse C/C++ IDE

I also have some paho-mqtt.dll's I'm not sure how to get the example code up and running.

Thank you

标签: c eclipse mqtt
1条回答
【Aperson】
2楼-- · 2020-04-17 05:17

It means paho library is not linked. In Linux for a c program example you can link paho library by this way:

gcc -L{complete path for output folder} {filename}.c -l paho-mqtt3c

In my case it looks like:

gcc -L/home/jaydev/MQTT/org.eclipse.paho.mqtt.c/build/output test2.c -lpaho-mqtt3c
查看更多
登录 后发表回答