c - gcc -lmosquitto 时的链接错误
问题描述
我在我的橙色 pi 上下载并安装 mosquitto-1.5.8.tar.gz,然后编写一个程序来测试它:
#include <stdio.h>
#include <mosquitto.h>
int main(void){
mosquitto_lib_init();
printf("OK\n");
mosquitto_lib_cleanup();
}
但是当我尝试编译它时,我得到了这个错误:
`root@orangepilite:/# gcc test.c -o test
/tmp/ccMUyHdP.o: In function `main':
test.c:(.text+0x4): undefined reference to 'mosquitto_lib_init'
test.c:(.text+0x14): undefined reference to 'mosquitto_lib_cleanup'
collect2: error: ld returned 1 exit status`
然后我试试这个:
root@orangepilite:/# gcc test.c -o test -lmosquitto
/usr/bin/ld: warning: librt.so.0, needed by /usr/lib/gcc/arm-linux-
gnueabihf/5/../../../arm-linux-gnueabihf/libmosquitto.so, not found (try
using -rpath or -rpath-link)
/usr/bin/ld: warning: libc.so.0, needed by /usr/lib/gcc/arm-linux-
gnueabihf/5/../../../arm-linux-gnueabihf/libmosquitto.so, not found (try
using -rpath or -rpath-link)
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../arm-linux-
gnueabihf/libmosquitto.so: undefined reference to `fcntl64'
collect2: error: ld returned 1 exit status
我是 mosquitto 和 linux 的新手,我真的不知道是什么问题,希望有人能帮助我。
这是 API 链接http://mosquitto.org/api/files/mosquitto-h.html,在这里下载mosquitto.org/download
解决方案
推荐阅读
- r - 为什么每次在 r 中的函数内部都使用 print()
- stripe-payments - 带 sca 的条带计划动态计划
- python - 第二次下载我写的代码中下载并保存的文件时,我可以更改名称吗?
- python - Force_authenticate 超级用户 django rest 单元测试
- c# - 能否帮助我理解列表的复杂性
. 排序方法? - firebase - Flutter Firebase 从文档引用列表中获取文档快照列表流
- c - 为浮点数获取错误的 printf 输出
- bash - rm -r 命令在 macos catalina 的 shell 内不起作用
- asterisk - 删除 FreePBX 快速拨号
- android - Gradle 同步失败:索引 53 处的非法字符 <:> - 离子电容器