Error building with rapidjson

I’m trying to include rapidjson in my project so that I can reuse parsing code from a different project.
Rapidjson is header only.
Rapidjson builds in a separate project built with he same flags but without oF.
The build fails when using make, and I don’t know why. I’m working on a debian x86_64 box. make output follows:

HOST_OS=Linux
HOST_ARCH=x86_64
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gl glu glew gtk+-3.0 libmpg123 
make: Warning: File 'config.shared.mk' has modification time 115170 s in the future
Compiling OF library for Debug
make -C ../../../libs/openFrameworksCompiled/project/ Debug PLATFORM_OS=Linux ABIS_TO_COMPILE_DEBUG=""
make[1]: Entering directory '/home/username/projects/openFrameworks/libs/openFrameworksCompiled/project'
HOST_OS=Linux
HOST_ARCH=x86_64
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gl glu glew gtk+-3.0 libmpg123 
HOST_OS=Linux
HOST_ARCH=x86_64
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gl glu glew gtk+-3.0 libmpg123 
make[2]: 'DebugABI' is up to date.
HOST_OS=Linux
HOST_ARCH=x86_64
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gl glu glew gtk+-3.0 libmpg123 
Done!
make[1]: Leaving directory '/home/username/projects/openFrameworks/libs/openFrameworksCompiled/project'


Compiling id for Debug
make[1]: Entering directory '/home/username/projects/openFrameworks/apps/projections/id'
HOST_OS=Linux
HOST_ARCH=x86_64
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa gl glu glew gtk+-3.0 libmpg123 
make[1]: Warning: File 'config.project.mk' has modification time 115636 s in the future
Compiling src/descriptor.cpp
g++ -c -g3 -Wall -std=c++14 -march=native -mtune=native -DOF_USING_GTK -DOF_USING_GTK -DOF_USING_MPG123 -I./addons -I./examples -I./rapidjson -I./rapidjson/src -I./rapidjson/src/rapidjson -I./rapidjson/src/rapidjson/error -I./rapidjson/src/rapidjson/internal -I./src -I./web -I./web/component -I./web/css -I./web/javascript -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/alsa -I/usr/include/GL -I/usr/include/libdrm -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../../libs/fmodex/include -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/kiss/include -I../../../libs/poco/include -I../../../libs/portaudio/include -I../../../libs/tess2/include -I../../../libs/utf8cpp/include -I../../../libs/utf8cpp/include/utf8 -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/video  -MMD -MP -MF obj/linux64/Debug/src/descriptor.d -MT obj/linux64/Debug/src/descriptor.o -o obj/linux64/Debug/src/descriptor.o -c src/descriptor.cpp
Compiling src/main.cpp
g++ -c -g3 -Wall -std=c++14 -march=native -mtune=native -DOF_USING_GTK -DOF_USING_GTK -DOF_USING_MPG123 -I./addons -I./examples -I./rapidjson -I./rapidjson/src -I./rapidjson/src/rapidjson -I./rapidjson/src/rapidjson/error -I./rapidjson/src/rapidjson/internal -I./src -I./web -I./web/component -I./web/css -I./web/javascript -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/alsa -I/usr/include/GL -I/usr/include/libdrm -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../../libs/fmodex/include -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/kiss/include -I../../../libs/poco/include -I../../../libs/portaudio/include -I../../../libs/tess2/include -I../../../libs/utf8cpp/include -I../../../libs/utf8cpp/include/utf8 -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/video  -MMD -MP -MF obj/linux64/Debug/src/main.d -MT obj/linux64/Debug/src/main.o -o obj/linux64/Debug/src/main.o -c src/main.cpp
In file included from ./rapidjson/src/rapidjson/document.h:20:0,
                 from src/params.h:14,
                 from src/ofApp.h:7,
                 from src/main.cpp:2:
./rapidjson/src/rapidjson/reader.h:188:15: error: expected unqualified-id before ‘bool’
     bool Bool(bool) { return static_cast<Override&>(*this).Default(); }
               ^
./rapidjson/src/rapidjson/reader.h:188:15: error: expected ‘)’ before ‘bool’
In file included from /usr/include/GL/glx.h:30:0,
                 from ../../../libs/openFrameworks/utils/ofConstants.h:179,
                 from ../../../libs/openFrameworks/ofMain.h:5,
                 from src/main.cpp:1:
./rapidjson/src/rapidjson/reader.h: In member function ‘void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseTrue(InputStream&, Handler&)’:
./rapidjson/src/rapidjson/reader.h:570:26: error: expected unqualified-id before ‘int’
             if (!handler.Bool(true))
                          ^
./rapidjson/src/rapidjson/reader.h:570:26: error: expected ‘)’ before ‘int’
./rapidjson/src/rapidjson/reader.h: In member function ‘void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseFalse(InputStream&, Handler&)’:
./rapidjson/src/rapidjson/reader.h:583:26: error: expected unqualified-id before ‘int’
             if (!handler.Bool(false))
                          ^
./rapidjson/src/rapidjson/reader.h:583:26: error: expected ‘)’ before ‘int’
./rapidjson/src/rapidjson/document.h: In member function ‘bool rapidjson::GenericValue<Encoding, Allocator>::Accept(Handler&) const’:
./rapidjson/src/rapidjson/document.h:1487:44: error: expected unqualified-id before ‘int’
         case kFalseType:    return handler.Bool(false);
                                            ^
./rapidjson/src/rapidjson/document.h:1487:44: error: expected ‘;’ before ‘int’
./rapidjson/src/rapidjson/document.h:1488:44: error: expected unqualified-id before ‘int’
         case kTrueType:     return handler.Bool(true);
                                            ^
./rapidjson/src/rapidjson/document.h:1488:44: error: expected ‘;’ before ‘int’
In file included from src/params.h:14:0,
                 from src/ofApp.h:7,
                 from src/main.cpp:2:
./rapidjson/src/rapidjson/document.h: At global scope:
./rapidjson/src/rapidjson/document.h:1918:15: error: expected unqualified-id before ‘bool’
     bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; }
               ^
./rapidjson/src/rapidjson/document.h:1918:15: error: expected ‘)’ before ‘bool’
In file included from src/ofApp.h:7:0,
                 from src/main.cpp:2:
src/params.h: In member function ‘descriptor_t* Params::parseUpdate(std::string)’:
src/params.h:184:5: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^
compile.project.mk:183: recipe for target 'obj/linux64/Debug/src/main.o' failed
make[1]: *** [obj/linux64/Debug/src/main.o] Error 1
make[1]: Leaving directory '/home/username/projects/openFrameworks/apps/projections/id'
compile.project.mk:137: recipe for target 'Debug' failed
make: *** [Debug] Error 2

This issue was caused by a macro in /usr/include/X11/Xlib.h: #define Bool int.

My work around was to include rapidjson/document.h before any include of X11/Xlib.h, which is effectively before any oF source header.

https://code.mythtv.org/trac/ticket/12065

When you say oF source header are you talking about the headers in path/to/openframeworks/libs/ or the project files like ofMain and ofApp?

I’m getting this error trying to include another library which uses rapidjson

EDIT: never mind, I hadn’t installed the binaries I was meant to and ding that fixed it :smiley: