问题一:问题描述:
在centos7上编译mosquitto源码时,出现以下问题:
make[1]: 进入目录“/home/jason/mosquitto-1.2/man”xsltproc mosquitto.8.xmlwarning: failed to load external entity "/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl"compilation error: file manpage.xsl line 3 element importxsl:import : unable to load /usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xslcompilation error: file mosquitto.8.xml line 4 element refentryxsltParseStylesheetProcess : document is not a stylesheetmake[1]: *** [mosquitto.8] 错误 5make[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
重新设置一下此文件的格式,然后保存退出即可