mac 搭建 c mqtt 二次开发环境搭建
# 下载源码
git clone https://github.com/eclipse/paho.mqtt.c.git
# 使用make 编译
cd paho.mqtt.c
# make mac上可能会报错 openssl 错误 使用 brew install openssl
make
sudo make install
# 默认安装在 /usr/local 目录下面
ls -l libpaho*
使用 C/C++ Project Generator 生成的c 工程目录 编译失败
Undefined symbols for architecture x86_64:
"_MQTTClient_connect", referenced from:
_main in main.o
"_MQTTClient_create", referenced from:
_main in main.o
"_MQTTClient_destroy", referenced from:
_main in main.o
"_MQTTClient_disconnect", referenced from:
_main in main.o
"_MQTTClient_publishMessage", referenced from:
_main in main.o
"_MQTTClient_waitForCompletion", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
在 makefile 设置 LFLAGS为
LFLAGS = -lpaho-mqtt3c -lpaho-mqtt3a
使用make 编译报错,解决方法(重要的事情说3次)
在 makefile 设置 LFLAGS为: LFLAGS = -lpaho-mqtt3c -lpaho-mqtt3a
在 makefile 设置 LFLAGS为: LFLAGS = -lpaho-mqtt3c -lpaho-mqtt3a
在 makefile 设置 LFLAGS为: LFLAGS = -lpaho-mqtt3c -lpaho-mqtt3a