Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error compiling Mosquitto 1.4

Tags:

mqtt

mosquitto

I have tried to compile Mosquitto on both Arch and CentOS 7, but everytime I get the same error. I want to test the Websocket feature.

This is the procedure I am using 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 https://github.com/warmcat/libwebsockets.git

cd libwebsockets/

mkdir build;cd build

cmake ..

make

make install

git clone https://git.eclipse.org/r/mosquitto/org.eclipse.mosquitto

cd org.eclipse.mosquitto/

git checkout origin/1.4

vi config.mk

Change "WITH_WEBSOCKETS:=yes"

make

And this is where it dies on 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 function ‘main’:
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 please point out what I am doing wrong or missing ?

like image 294
Gregg Avatar asked Jun 19 '26 19:06

Gregg


1 Answers

As @hardillb says, the VERSION defines are the problem. If I add the line

#define VERSION

to mosquitto.c, then I can reproduce the error that you see, but also get a warning about redefining VERSION.

If I remove the definition of VERSION from config.mk, then I get an error about VERSION not being defined.

These both make sense.

What seems to be happening for you is that the compiler is ignoring the command line definition -DVERSION="\"1.4.1\"" and replacing it with -DVERSION=, or isn't parsing the string properly. This doesn't make sense.

Other people have managed to compile on Arch, and the CentOS7 repository has a binary version - but without websockets.


After some investigation, it appears as though there is a bug in recent libwebsockets code. This changeset introduces some changes that mean that libwebsockets is claiming the macro VERSION all for itself, which isn't very polite for a library. If you use a released version of libwebsockets you should not have any problem compiling.

like image 89
ralight Avatar answered Jun 24 '26 11:06

ralight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!