Example MQTT Client Code not working C

不想你离开。 提交于 2019-12-02 11:17:42

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/32005906/example-mqtt-client-code-not-working-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!