编译安装mosquitto过程记录

克隆mosquitto源代码

首先需要检查是否已经安装了openssl和cJSON,没有安装则先安装

git clone https://github.com/eclipse/mosquitto.git

编译安装

cd mosquitto
mkdir build && cd build/
cmake ..

执行到cmake …时,提示如下

sunrise@ubuntu:~/Repo/mosquitto/build$ cmake ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib/aarch64-linux-gnu/libcrypto.so (found version "1.1.1f")
-- WITH_DLT = OFF
-- Found cJSON: /usr/include
-- TRUE
-- Looking for getaddrinfo_a in anl
-- Looking for getaddrinfo_a in anl - found
CMake Error at man/CMakeLists.txt:46 (message):
  xsltproc not found: manpages cannot be built


-- Configuring incomplete, errors occurred!
See also "/home/sunrise/Repo/mosquitto/build/CMakeFiles/CMakeOutput.log".

我们需要安装一下xsltproc和docbook-xsl,执行以下命令即可

sudo apt update
sudo apt install xsltproc
sudo apt install docbook-xsl

再次执行cmake …

sunrise@ubuntu:~/Repo/mosquitto/build$ cmake ..
-- WITH_DLT = OFF
-- TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sunrise/Repo/mosquitto/build

然后编译安装mosquito

make
sudo make install

运行测试

在终端运行以下指令则可开启MQTT服务

mosquitto

新开一个终端,启动订阅者

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
mosquitto_sub -t test

再新开一个终端,运行发布者

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
mosquitto_pub -h localhost -t test -m "hello world"

每运行一次则在订阅者终端打印一次hello world

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译mosquitto.dll,你需要按照以下步骤进行操作: 1. 首先,你需要下载mosquitto的源代码。你可以在mosquitto的GitHub项目地址(https://github.com/eclipse/mosquitto)上找到源代码。你可以通过访问官方网站(https://mosquitto.org/download/)下载源代码。 2. 在下载源代码后,你需要进行一些准备工作。根据引用\[2\]中的说明,你需要修改变量LIB_EAY_RELEASE和SSL_EAY_RELEASE的值,分别指向libcrypto.dll.a和libssl.dll.a动态库的位置。你还可以修改CMAKE_INSTALL_PREFIX路径,以指定安装位置。 3. 接下来,你需要安装pthread库。根据引用\[3\]中的说明,你可以访问Pthreads-Win32的官方网站(ftp://sourceware.org/pub/pthreads-win32/dll-latest)下载所需的DLL、LIB和头文件。你可以使用xftp7等工具进行下载。 4. 在完成上述准备工作后,你可以开始编译mosquitto.dll。具体的编译过程可以参考mosquitto的GitHub说明文档,其中包含了详细的编译步骤和命令。 请注意,编译mosquitto.dll可能涉及到其他依赖项和配置,具体的步骤可能因操作系统和编译环境而有所不同。建议你在编译之前仔细阅读mosquitto的文档和相关资源,以确保正确地完成编译过程。 #### 引用[.reference_title] - *1* [mosquitto在windows10中VS2019进行编译出lib和dll](https://blog.csdn.net/chuyanghong/article/details/126915202)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [在win64下编译支持双证书的mosquitto](https://blog.csdn.net/qq_43229894/article/details/127814278)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值