gcc -lmosquitto

时间:2019-03-19 05:47:40

标签: c linux gcc linker-errors mosquitto

我在橙色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下载

0 个答案:

没有答案