使用 g++ 使用 mosquitto 库编译 cpp 代码时出错

Error compiling cpp code with mosquitto library with g++

我正在尝试使用 mosquitto 编译 c++ 代码,我在 raspberry pi 中下载了客户端的数据包,我想 运行 在那里。

我使用以下命令下载:

sudo apt-get install mosquitto mosquitto-clients

但我认为库没有正确索引,因为当我尝试使用 g++ 编译器编译我的代码时,它给我一个错误:

cannot find -lmosquitto

我正在使用以下命令进行编译:

g++ -o mosquito mosquito.cpp -lmosquitto

你应该安装用于开发的 libmosquitto-dev

所以你应该这样做

sudo apt-get install libmosquitto-dev