[英]Install and use MQTT Paho libraries for C++
I hope my problem is simple to resolve.我希望我的问题很容易解决。 I should to use mqtt protocol with my Raspberry Pi v2, so now I'm trying it with Paho libraries:
我应该在我的 Raspberry Pi v2 中使用 mqtt 协议,所以现在我正在尝试使用 Paho 库:
http://www.eclipse.org/paho/ http://www.eclipse.org/paho/
I use C++ language, so I wrote first these commands我使用C++语言,所以我先写了这些命令
git clone http://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.c.git
cd org.eclipse.paho.mqtt.c.git
make
sudo make install
and then these然后这些
git clone http://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.cpp.git
cd org.eclipse.paho.mqtt.cpp.git
make
Now I have two questions:现在我有两个问题:
mqtt::client
.mqtt::client
。 I have tried to include client.h
(i found it in the documentation) but the compiler doesn't find it.client.h
(我在文档中找到了它)但编译器没有找到它。lib/linmqttpp.so.0.1
.lib/linmqttpp.so.0.1
的 make 命令。 I must link it in the compile command?currently in the paho c++ in the git project it is not building correctly for new users.当前在 git 项目的 paho c++ 中,它没有为新用户正确构建。 it creates an empty c++ library when you do a make so any code you link against that will fail with undefined method.
当您执行 make 时,它会创建一个空的 C++ 库,因此您链接的任何代码都将因未定义的方法而失败。 you can check by running this command to see what is available in your library.
您可以通过运行此命令来查看库中的可用内容。
nm -g lib/linmqttpp.so.0.1
You will see it is empty.你会看到它是空的。
Also if you copied and passed the example code from the website then it will not work.此外,如果您从网站复制并传递了示例代码,则它将无法正常工作。 It needs other code beside what is on the website.
除了网站上的内容之外,它还需要其他代码。 It just gives you a code snippet.
它只是给你一个代码片段。
Example code is in this directory.示例代码在此目录中。
src/samples
Currently the make file for the sample files will fail.目前,示例文件的 make 文件将失败。
I have submitted a patch just now to the project to fix the main build and the sample files build.我刚刚向项目提交了一个补丁来修复主构建和示例文件构建。 Once that is applied the project will build correctly you can start hacking the sample files.
一旦应用,项目将正确构建,您可以开始破解示例文件。
With regards the C++ project not installing its because there is no target in the make file to do an install.关于 C++ 项目没有安装它,因为 make 文件中没有目标来进行安装。 if you want for now copy the files that are created in lib to the below with sudo permissions.
如果您现在想要使用 sudo 权限将在 lib 中创建的文件复制到下面。 /usr/local/lib/
/usr/local/lib/
Then you can access the shared libraries from any project.然后您可以从任何项目访问共享库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.