c - 在树莓派上安装 mqtt 客户端库
问题描述
我一直在尝试在 raspbian buster 上编译 Paho MQTT 客户端库。克隆了github源码:
git clone https://github.com/eclipse/paho.mqtt.c.git
根据 README 文件,我运行了 make(除了 1 个警告“rc1 not used”之外,还可以),然后 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
MQTTClient.h 和 MQTTClient.c 存在于 /usr/include 中,请问我做错了什么?
解决方案
推荐阅读
- c - C 代码、指针及其内容。考试题
- jenkins-pipeline - 参数化 Jenkins 管道使用不同的工作流程
- reactjs - TS 和反应状态 - 'RangeModifier' 类型的参数不可分配给类型的参数
- python - 如何使用 python 提高这个解析器的速度?
- php - 如何为访问 PHP 网站的访问者分配随机会话密钥?
- apache-flink - flink集群启动报错【ERROR】无法正确获取JVM参数
- java - 如何使用在查询中重复的值为 PreparedStatement 创建正确的 sql 查询(字符串)?
- amazon-web-services - 如何通过 Terraform 启动没有密钥对的 EC2 实例?
- python - 如何为列表中的每个元素添加值?
- terraform - 如何在 terraform DSL 中导入 Datadog JSON 模板?