mosquitto 编译
参考
https://goochgooch.wordpress.com/2014/08/01/building-mosquitto-1-4/
https://github.com/eclipse/mosquitto
https://github.com/bapowell/bapowell.github.io/wiki/Mosquitto-Build-Notes-(Linux)
下载源码
git clone git@github.com:eclipse/mosquitto.git
安装依赖
- sudo apt-get install uuid-dev xsltproc docbook-xsl libssl-dev
- 提示 ares.h 找不到, 安装 c-ares
wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz
tar xvf c-ares-1.10.0.tar.gz
cd c-ares-1.10.0/
./configure
sudo make install
修改 config.mk
c-ares (libc-ares-dev on Debian based systems) - disable with make WITH_SRV=no
libuuid (uuid-dev) - disable with make WITH_UUID=no
libwebsockets (libwebsockets-dev) - enable with make WITH_WEBSOCKETS=yes
openssl (libssl-dev on Debian based systems) - disable with make WITH_TLS=no
- 可以修改编译选项,跳过生成doc,则注释掉 WITH_DOCS
#WITH_DOCS:=yes
编译
make binary
测试
-
服务端 mosquitto
在源码根目录 ./src/mosquitto -
客户端 mosquito_sub,mosquito_pub
在源码根目录 ./client/mosquitto
》mosquitto_pub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory
/sbin/ldconfig as root/sudo
- 测试
>./src/mosquitto &
1500302756: mosquitto version 1.4.13 (build date 2017-07-17 22:19:54+0800) starting
1500302756: Using default config.
1500302756: Opening ipv4 listen socket on port 1883.
1500302756: Opening ipv6 listen socket on port 1883.
>mosquitto_sub -t "topic" &
1500302862: New connection from 127.0.0.1 on port 1883.
1500302862: New client connected from 127.0.0.1 as mosq_sub_21276_ra1z (c1, k60).
>mosquitto_pub -t "topic" -m "hello"
1500302977: New connection from 127.0.0.1 on port 1883.
1500302977: New client connected from 127.0.0.1 as mosq_pub_21278_ra1z (c1, k60).
1500302977: Client mosq_pub_21278_ra1z disconnected.
hello
安装到系统
make install
环境
bash on ubuntu on windows