记录一次过程(1):Building Mosquitto from the git repository

栏目: 编程工具 · 发布时间: 6年前

内容简介:Mosquittto是针对MQTT 3.1版本和3.1.1版本的一个开源实现的服务器。它包含C和C++的客户端库,以及用于publish/subscribe的实用程序:mosquitto_pub/mosquitto_sub。使用命令

Mosquitto

Mosquittto是针对MQTT 3.1版本和3.1.1版本的一个开源实现的服务器。它包含C和C++的客户端库,以及用于publish/subscribe的实用程序:mosquitto_pub/mosquitto_sub。

Mosquitto项目 对于如何Building from source描述并不足够清晰,但其实步骤也还算简单。

步骤

1.cmake

使用命令 cmake -DWITH_TLS_PSK=OFF -DWITH_TLS=OFF 得到

-- Configuring done

这两行中间有warning,由于我只是需要搭建一个简单的环境做简单地测试,就没有管warning。

2.make

使用命令 make 得到

[100%] Linking C executable mosquitto

3.sudo make install

使用命令 sudo make install 报错。报错信息如下:

Install the project...

-- Install configuration: ""

-- Up-to-date: /usr/local/etc/mosquitto/mosquitto.conf

-- Up-to-date: /usr/local/etc/mosquitto/aclfile.example

-- Up-to-date: /usr/local/etc/mosquitto/pskfile.example

-- Up-to-date: /usr/local/etc/mosquitto/pwfile.example

-- Up-to-date: /usr/local/lib/pkgconfig/libmosquitto.pc

-- Up-to-date: /usr/local/lib/pkgconfig/libmosquittopp.pc

-- Installing: /usr/local/lib/libmosquitto.1.5.5.dylib

-- Up-to-date: /usr/local/lib/libmosquitto.1.dylib

-- Up-to-date: /usr/local/lib/libmosquitto.dylib

-- Up-to-date: /usr/local/include/mosquitto.h

-- Installing: /usr/local/lib/libmosquittopp.1.5.5.dylib

-- Up-to-date: /usr/local/lib/libmosquittopp.1.dylib

-- Up-to-date: /usr/local/lib/libmosquittopp.dylib

-- Up-to-date: /usr/local/include/mosquittopp.h

-- Installing: /usr/local/bin/mosquitto_pub

-- Installing: /usr/local/bin/mosquitto_sub

-- Installing: /usr/local/sbin/mosquitto

-- Up-to-date: /usr/local/include/mosquitto_broker.h

-- Up-to-date: /usr/local/include/mosquitto_plugin.h

CMake Error at man/cmake_install.cmake:36 (file):

file INSTALL cannot find

"/Users/xxxx/Desktop/iMac-mosquitto/mosquitto-master/man/mosquitto_passwd.1".

Call Stack (most recent call first):

cmake_install.cmake:57 (include)

make: * [install] Error 1

报错之后首先检查报错信息,google之后仍然有解决方面的困难。这时我们注意到上面加粗的三行,切换到安装目录 /usr/local/include/ 后运行命令 mosquitto 发现可以运行,但是在安装目录外就不可以运行。

这时候我们的下一步就是配置环境变量,从而使mosquitto的运行不受当前目录的限制。

4.添加环境变量

环境变量的作用是:可以在操作系统的各个目录下,都能访问到需要的 工具 目录内的内容。

我参考的是 Mac OS X 系统的环境变量配置

分别将/usr/local/bin/以及/usr/local/sbin/加入环境变量之后(我将路径加入了用户级的~/.bash_profile),就可以运行mosquitto了。

但是还有一个烦人的小问题,就是Mac每次都要执行source ~/.bash_profile,配置的环境变量才生效。 解决方法 是:

在~/.zshrc文件最后,增加一行:

5.运行测试

先开一个terminal,输入命令 mosquitto

打开第二个terminal,输入命令 mosquitto_sub -h localhost -t test

打开第三个terminal,输入命令 mosquitto_pub -h localhost -t test -m "hello world"

发现在第二个terminal上出现了hello world字符串,即成功。

6.思考几个问题,后续解决。

直接用 cmake . 是会由于OpenSSL的路径问题报错的,OpenSSL是干什么用的?

我没有去解决OpenSSL的路径问题,而是忽略了它,关闭了TLS直接cmake的。TLS又是什么?起到了什么作用?

程序运行起来经过了哪些步骤?

一个大型项目是如何安装运行起来的?

为什么安装mosquitto的步骤是cmake->make->sudo make install?


以上所述就是小编给大家介绍的《记录一次过程(1):Building Mosquitto from the git repository》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Programming in Java

Introduction to Programming in Java

Robert Sedgewick、Kevin Wayne / Addison-Wesley / 2007-7-27 / USD 89.00

By emphasizing the application of computer programming not only in success stories in the software industry but also in familiar scenarios in physical and biological science, engineering, and appli......一起来看看 《Introduction to Programming in Java》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换