我一直在尝试在树莓派破坏者上编译Paho MQTT客户端库。克隆了github源:
git clone https://github.com/eclipse/paho.mqtt.c.git
根据自述文件,我运行make(除了1条警告“ rc1 not used”(警告未使用rc),然后运行),然后进行sudo make install,它可以将各种MQTTxx.h和MQTTxx.c文件复制到/ usr / include目录中。
但是,尝试编译Paho演示程序会导致:
richard@grigio:[~]: gcc mqtest.c
/tmp/ccvjYcVw.o: In function `main':
mqtest.c:(.text+0x68): undefined reference to `MQTTClient_create'
mqtest.c:(.text+0x8c): undefined reference to `MQTTClient_connect'
mqtest.c:(.text+0xe4): undefined reference to `MQTTClient_publishMessage'
mqtest.c:(.text+0x114): undefined reference to `MQTTClient_waitForCompletion'
mqtest.c:(.text+0x138): undefined reference to `MQTTClient_disconnect'
mqtest.c:(.text+0x144): undefined reference to `MQTTClient_destroy'
collect2: error: ld returned 1 exit status
所以我认为我需要链接库:
richard@grigio:[~]: gcc mqtest.c -lMQTTClient
/usr/bin/ld: cannot find -lMQTTClient
collect2: error: ld returned 1 exit status
/ usr / include中存在MQTTClient.h和MQTTClient.c,请问我做错了什么?