mosquitto 使用时出现的一些问题及其解决办法
問題一:問題描述:
在centos7上編譯mosquitto源碼時,出現以下問題:
?
?make[1]: 進入目錄“/home/jason/mosquitto-1.2/man”
xsltproc mosquitto.8.xml
warning: failed to load external entity "/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl"
compilation error: file manpage.xsl line 3 element import
xsl:import : unable to load /usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl
compilation error: file mosquitto.8.xml line 4 element refentry
xsltParseStylesheetProcess : document is not a stylesheet
make[1]: *** [mosquitto.8] 錯誤 5
make[1]: 離開目錄“/home/jason/mosquitto-1.2/man”
make: *** [docs] 錯誤 2
由提示可以看到,此時問題的原因在于在文件:manpage.xsl里面加載不了:docbook.xsl所致,錯誤提示中也顯示在絕對路徑:
?
/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl
下找不到這個文件:
?docbook.xsl
再看文件manpage.xsl里,按照所提示第3行,果然是這個絕對地址:
?
?<!-- Set parameters for manpage xsl -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl"/>
<!-- Don't display notes list of link urls. -->
<xsl:param name="man.endnotes.list.enabled">0</xsl:param>
<xsl:param name="man.endnotes.are.numbered">0</xsl:param>
<!-- But if we do, set a base url for the relative links. -->
<xsl:param name="man.base.url.for.relative.links">http://mosquitto.org/man/</xsl:param>
<!-- Don't output filename when generating. -->
<xsl:param name="man.output.quietly" select="1"></xsl:param>
<!-- Generate ansi style function synopses. -->
<xsl:param name="man.funcsynopsis.style">ansi</xsl:param>
</xsl:stylesheet>
?
?
通過命令查找文件?docbook.xsl,在本機中也沒有發現,因此基本可以確定是找不到這個文件所致:
[root@localhost mosquitto-1.2]# find / -name docbook.xsl
?
解決辦法:
1.安裝docbook-style-xsl
使用命令:yum -y install docbook-style-xsl
2.查看文件docbook.xsl被安裝到了哪里:
例如:
[root@localhost tools]# find / -name docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/epub/docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/fo/docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/html/docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/manpages/docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/xhtml/docbook.xsl
/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/xhtml-1_1/docbook.xsl
3.搜索到之后,將上面紅字中的地址修改到文件manpage.xsl里的對應位置;
4.再重新編譯mosquitto,問題已經解決!
?
問題二:執行mosquitto客戶端程序時出現找不到動態庫:libmosquitto.so.1
./mosquitto_sub: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory
?
執行命令:
sudo ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1
和
ldconfig
即可
?
問題三:?Invalid user 'mosquitto'.
?
?[root@localhost src]# ./mosquitto
1437558553: Error: Invalid user 'mosquitto'.
兩種解決辦法:
?
(1)修改配置文件:mosquitto.conf ,增加登錄的用戶,例如當前登錄用戶為root
(1)執行命令增加當前用戶:
?adduser mosquitto
如下圖:
問題四:
在修改mosquitto源碼之后,換到centos環境下重新編譯時可能會出現下面的問題:
mosquitto.c:271:2: 錯誤:缺少結尾的 " 字符
? snprintf(buf, 1024, "%s", CHANGESET);
? ^
mosquitto.c:271:37: 錯誤:expected expression before ‘)’ token
? snprintf(buf, 1024, "%s", CHANGESET);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^
該問題的原因是文件:changeset的格式不對,可在centos環境下,按照如下方式修改此文件的格式:
使用vi打開此文件,然后使用:
:set ff=unix
重新設置一下此文件的格式,然后保存退出即可
問題五:xsltproc: Command not found
mosquitto編譯的時候出現問題:xsltproc: Command not found
如下圖所示:
解決辦法:安裝libxslt
yum -y install libxslt
問題六:
?
./mosquitto_internal.h:40:20: error: ares.h: No such file or directory
解決辦法:
- 方法1關掉:則要到configure.mk文件中,把配置項WITH_SRV關掉,再編譯就行了如下:
WITH_SRV=no
- 方法2啟用:
cd <SRC>?
wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gztar xvf c-ares-1.10.0.tar.gz
cd c-ares-1.10.0
./configure
make
sudo make install
總結
以上是生活随笔為你收集整理的mosquitto 使用时出现的一些问题及其解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 服务器带宽异常跑满分析解决
- 下一篇: paho mqtt client调试记录