Compile error Mosquitto 1.4

I tried to compile Mosquitto on Arch and CentOS 7, but I get the same error every time. I want to test the Websocket function.

This is the procedure I use for CentOS:

yum group install "Development Tools"

yum install cmake openssl-devel cmake

yum install uuid-devel libxslt docbook5-style-xsl.noarch docbook-style-xsl.noarch

git clone

cd libwebsockets /

mkdir build; cd build

cmake ..

to do

make installation

git clone

cd org.eclipse.mosquitto /

git homing /1.4


Change "WITH_WEBSOCKETS: = yes"

to do

And here it dies from Arch and CentOS:

make[1]: Entering directory '/home/install/org.eclipse.mosquitto/src'
cc -Wall -ggdb -O2  -I. -I.. -I../lib  -DVERSION="\"1.4\""   -DTIMESTAMP="\"2015-05-04 17:17:55+0200\"" -DWITH_BROKER -DWITH_TLS -DWITH_TLS_PSK -DWITH_UUID -DWITH_BRIDGE -DWITH_PERSISTENCE -DWITH_MEMORY_TRACKING -DWITH_SYS_TREE -DWITH_WEBSOCKETS -DWITH_EC -c mosquitto.c -o mosquitto.o

In file included from /usr/include/unistd.h:25:0,
             from mosquitto.c:22:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and  _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
mosquitto.c: In functionmain’:
mosquitto.c:275:101: error: expected expression before ‘,’ token
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "mosquitto version %s (build date %s) starting", VERSION, TIMESTAMP);
 mosquitto.c:290:54: error: expected expression before ‘)’ token
snprintf(buf, 1024, "mosquitto version %s", VERSION);
mosquitto.c:368:88: error: expected expression before ‘)’ token
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "mosquitto version %s terminating", VERSION);
Makefile:15: recipe for target 'mosquitto.o' failed
make[1]: *** [mosquitto.o] Error 1
make[1]: Leaving directory '/home/install/org.eclipse.mosquitto/src'
Makefile:21: recipe for target 'mosquitto' failed
make: *** [mosquitto] Error 2


If someone can point out what I am doing wrong or missing?


source to share

2 answers

As @hardillb says the VERSION issue is the issue. If I add the line

#define VERSION


before mosquitto.c, then I can reproduce the error you are seeing but also get a version override warning.

If I remove the VERSION definition from then I get an error where VERSION is not defined.

They both make sense.

It seems that it seems to you that the compiler ignores the command line definition -DVERSION="\"1.4.1\""

and replaces it with -DVERSION=

or does not parse the line correctly. This makes no sense.

Other people have managed to compile Arch and the CentOS7 repository has a binary version but no websites.

After some investigation, it seems that there is a bug in the latest libwebsockets code. This changeset contains some changes that mean libwebsockets is asking the macro VERSION

for everything for itself, which is not very polite for the library. If you are using a released version of libwebsockets, you should have no problem compiling.



Just out of interest, you were trying to build from the TGZ src package for Mosquitto 1.4.1, available here:

Errors must be related to the expansion of the passed VERSION and TIMESTAMP values. It works fine [except for the docs] on Fedora 20, which shouldn't be that far from RHEL 7.0 (and from there to Centos 7).



All Articles