问题
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