Ubuntu 的版本为18.04
Mosquitto的版本为1.6.9:https://mosquitto.org/files/source/
Openssl的版本为1.1.1:https://www.openssl.org/source/old/index.html
注意:Ubuntu安装最新版本的mosquitto会报错,安装不成功。
第一步先安装cJSON:
参考的博客:cJSON库的安装与使用_libcjson.so-CSDN博客
git clone https://github.com/DaveGamble/cJSON.git
cd cJSON/
mkdir build
cd build/
cmake ..
make
make install
执行完上述命令后,cJSON.h 头文件会安装在 /usr/local/include/cjson 目录下。libcjson.so 库文件会安装在 /usr/local/lib 目录下。还需要将/usr/local/lib目录添加到 /etc/ld.so.conf 文件中,然后执行 /sbin/ldconfig,否则程序在运行时会报 error while loading shared libraries: libcjson.so.1: cannot open shared object file: No such file or directory 错误。
编程序时一般用cJSON.c和cJSON.h的源文件。
第二步:安装openssl
参考博客:Linux Ubuntu 20.04LTS安装OpenSSL步骤_ubuntu安装openssl-CSDN博客
openssl1.1.1安装错误_openssl library version... configure: error: opens-CSDN博客
参考视频:08_MQTT-mosquitto老版本移植受阻_哔哩哔哩_bilibili
2.去OpenSSL官网下载源码安装包:/source/old/index.html
3.解压安装装包
tar xvf openssl-1.1.1w.tar.gz
4.建立一个安装路径的文件
mkdir openssl-1.1.1w_install
5.设置安装路径:
sudo ./config no-asm -shared --prefix=/home/sysadm/mosquitto_work/openssl-1.1.1w_install
sudo make
sudo make install
6.最后,可以把这三个目录加到系统对应的环境变量里;
对所有用户有效修改 "/etc/profile" 可能需要重启系统才会生效
vim /etc/profile
7.使用命令可以查看是否安装成功
第三步:安装uuid
uuid用于产生唯一识别码
sudo apt-get install uuid-dev
第四步:安装mosquitto
mosquitto的旧版本的下载官网:Index of /files/source/
1.解压安装包:
tar xvf mosquitti-1.6.9.tar.gz
2.创建一个安装文件夹
3.配置环境变量
export DESTDIR=/home/guyao/desktop/mqtt_study/mqtt_for_raspberry/mosquitto-1.6.9_install
4.打开config.mk
vim config.mk
5.make
6.make install
7.记得一定要取消安装路径的配置,防止安装其他软件时会直接安装到刚在设置的安装路径。
export DESTDIR=
到此,ubuntu18.04系统的mosquito库基本上就安装成功了。