ofxJSON preprocessor errors... debug advice needed

This seems to be some preprocessor error. Just including the ofxJSON addon is enough to choke gcc in the preprocessing phase. Anybody any experience with debugging preprocessor errors?

I tried this on Debian Wheezy(gcc 4.7) and Ubuntu Precise(gcc 4.6) same errors. This doens’t happen on OSX (gcc 4.2). From google I get this comes from some preprocessor statements…

see: https://github.com/jefftimesten/ofxJSON/issues/2

I’ve narrowed the gcc command down to:

  
g++ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../libs/FreeImage/include -I../../../libs/assimp/include -I../../../libs/assimp/include/Compiler -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/cairo/include/pixman-1 -I../../../libs/cairo/include/libpng15 -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/kiss/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/videoInput/include -I../../../libs/poco/include -I../../../libs/openFrameworks/ -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/.settings -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/app -g3 -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/src -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/libs/src -I../../../addons/../../ofAddons/ofxJSON/libs/src/lib_json -I../../../addons/../../ofAddons/ofxJSON/libs/include -I../../../addons/../../ofAddons/ofxJSON/libs/include/json -Isrc -MMD -MP -MFobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.d -MTobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -o obj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -c ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp  

I’m using a different addon dir in case you wondered.

The error is huge but starts with this:

  
In file included from /usr/include/c++/4.6/cwchar:46:0,  
                 from /usr/include/c++/4.6/bits/postypes.h:42,  
                 from /usr/include/c++/4.6/iosfwd:42,  
                 from /usr/include/c++/4.6/ios:39,  
                 from /usr/include/c++/4.6/ostream:40,  
                 from /usr/include/c++/4.6/iostream:40,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.h:13,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp:10:  
/usr/include/wchar.h:75:43: error: missing binary operator before token "("  
In file included from /usr/include/sched.h:43:0,  
                 from /usr/include/pthread.h:25,  
                 from /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:41,  
                 from /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr.h:170,  
                 from /usr/include/c++/4.6/ext/atomicity.h:34,  
                 from /usr/include/c++/4.6/bits/ios_base.h:41,  
                 from /usr/include/c++/4.6/ios:43,  
                 from /usr/include/c++/4.6/ostream:40,  
                 from /usr/include/c++/4.6/iostream:40,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.h:13,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp:10:  
/usr/include/x86_64-linux-gnu/bits/sched.h:133:20: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/bits/sched.h:171:20: error: missing binary operator before token "("  
In file included from /usr/include/libio.h:62:0,  
                 from /usr/include/stdio.h:75,  
                 from /usr/include/c++/4.6/cstdio:44,  
                 from /usr/include/c++/4.6/fstream:43,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.h:14,  
                 from ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp:10:  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:43:20: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:56:44: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:61:44: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:149:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:162:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:224:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:233:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:240:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:249:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:258:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:270:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:280:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:289:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:297:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:311:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:319:43: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:342:19: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:351:20: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:356:20: error: missing binary operator before token "("  
/usr/include/x86_64-linux-gnu/sys/cdefs.h:363:19: error: missing binary operator before token "("  
In file included from /usr/include/X11/Xlib.h:38:0,  
etc......  

i adapted ofxJSON to work on linux in this branch of the OF repo:

https://github.com/arturoc/openFrameworks/tree/feature-ofParameter/addons

you’ll need to install

sudo apt-get install libjsoncpp-dev

and add the library and include paths in the config.make of your project, there’s an example in that same branch in devApps/parameterGroups:

https://github.com/arturoc/openFrameworks/blob/feature-ofParameter/apps/devApps/parameterGroupExample/config.make

Yep that nailed the bastard. :slight_smile:

It was my next move to use a static or dynamic lib. What’s ofParameterGroup btw? Couldn’t get your code to run because of that but used your approach to compile with the dynamic lib.

It is a weird problem however. I’ve been having more compiler issues lately which I guess are related to newer gcc versions. ie http://forum.openframeworks.cc/t/simple-preprocessor-issue…/10660/0

It might be usefull to have some more debugging powerrrrs for this.

Thanks for the suggestion!

This morning I though I’d try to refactor ofxJSON to use a static lib. This didn’t help my case. So back to some more digging.

I now have two places where my jsoncpp includes are located. The files are identical:

  
$ diff ~ofxJSON/libs/jsoncpp/include/json/ /usr/include/jsoncpp/json/  
$  
  

The makefile from OF will automatically search for the ‘include’ dir in the ofxJSON/libs/*/ dir.

I compile with the include dir in place. The compile fails.

Now I remove the include dir and use config.make to tell the compiler to use the /usr/include/jsoncpp/ dir.
USER_CFLAGS = -I/usr/include/jsoncpp

I compile again. The compile succeeds.

This leds me to believe this is a problem with the Makefile?

Current structure of the ofxJSON/libs dir:

  
libs/  
libs/jsoncpp  
libs/jsoncpp/src  
libs/jsoncpp/src/json_batchallocator.h  
libs/jsoncpp/src/sconscript  
libs/jsoncpp/src/json_internalarray.inl  
libs/jsoncpp/src/json_reader.cpp  
libs/jsoncpp/src/json_internalmap.inl  
libs/jsoncpp/src/json_writer.cpp  
libs/jsoncpp/src/json_tool.h  
libs/jsoncpp/src/json_value.cpp  
libs/jsoncpp/src/json_valueiterator.inl  
libs/jsoncpp/include  
libs/jsoncpp/include/json  
libs/jsoncpp/include/json/forwards.h  
libs/jsoncpp/include/json/reader.h  
libs/jsoncpp/include/json/autolink.h  
libs/jsoncpp/include/json/features.h  
libs/jsoncpp/include/json/config.h  
libs/jsoncpp/include/json/writer.h  
libs/jsoncpp/include/json/value.h  
libs/jsoncpp/include/json/json.h  
libs/version  
libs/README.txt  
  

Here some of my notes of failed and success compiles. It seems removing -I…/…/…/addons/…/…/ofAddons/ofxJSON/libs/jsoncpp/include/json option is the key to the error:

  
Fail:  
g++ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../libs/FreeImage/include -I../../../libs/assimp/include -I../../../libs/assimp/include/Compiler -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/cairo/include/pixman-1 -I../../../libs/cairo/include/libpng15 -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/kiss/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/videoInput/include -I../../../libs/poco/include -I../../../libs/openFrameworks/ -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/.settings -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/app -g3 -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/src -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/libs/src -I../../../addons/../../ofAddons/ofxJSON/libs/src/lib_json -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include/json -Isrc -MMD -MP -MFobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.d -MTobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -o obj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -c ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp    
  
Success -I/usr/include/jsoncpp:   
g++ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../libs/FreeImage/include -I../../../libs/assimp/include -I../../../libs/assimp/include/Compiler -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/cairo/include/pixman-1 -I../../../libs/cairo/include/libpng15 -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/kiss/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/videoInput/include -I../../../libs/poco/include -I../../../libs/openFrameworks/ -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/.settings -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/app -g3 -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/src -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/libs/src -I/usr/include/jsoncpp -Isrc -MMD -MP -MFobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.d -MTobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -o obj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -c ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp    
  
Success -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include:  
g++ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../libs/FreeImage/include -I../../../libs/assimp/include -I../../../libs/assimp/include/Compiler -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/cairo/include/pixman-1 -I../../../libs/cairo/include/libpng15 -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/kiss/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/videoInput/include -I../../../libs/poco/include -I../../../libs/openFrameworks/ -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/.settings -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/app -g3 -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/src -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/libs/src -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include -Isrc -MMD -MP -MFobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.d -MTobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -o obj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -c ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp  
  
Success from the failed one minus -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include/json:  
g++ -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../libs/FreeImage/include -I../../../libs/assimp/include -I../../../libs/assimp/include/Compiler -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/cairo/include/pixman-1 -I../../../libs/cairo/include/libpng15 -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/kiss/include -I../../../libs/portaudio/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/videoInput/include -I../../../libs/poco/include -I../../../libs/openFrameworks/ -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/.settings -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/app -g3 -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/src -I../../../addons/../../ofAddons/ofxJSON/libs -I../../../addons/../../ofAddons/ofxJSON/libs/src -I../../../addons/../../ofAddons/ofxJSON/libs/src/lib_json -I../../../addons/../../ofAddons/ofxJSON/libs/jsoncpp/include -Isrc -MMD -MP -MFobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.d -MTobj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -o obj/x86_64Debug/addons/../../ofAddons/ofxJSON/src/ofxJSONElement.o -c ../../../addons/../../ofAddons/ofxJSON/src/ofxJSONElement.cpp    

Ok I fixed it in the Makefile. This might be a change to include in OF?

  
--- libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples	(revision 6423)  
+++ libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples	(working copy)  
@@ -115,7 +115,7 @@  
 	    ADDONS_INCLUDES = $(ADDONS_DIRS)  
 	    ADDONS_INCLUDES = $(ADDONS_LIBS_DIRS)  
 	    ADDONS_INCLUDES += $(shell find $(ADDONS_DIRS) -type d 2> /dev/null)  
-	    ADDONS_INCLUDES += $(shell find $(ADDONS_LIBS_DIRS) -type d 2> /dev/null)  
+	    ADDONS_INCLUDES += $(shell find $(ADDONS_LIBS_DIRS) -name include -type d 2> /dev/null)  
 	    ADDONSCFLAGS = $(addprefix -I,$(ADDONS_INCLUDES))  
   
 	    ifeq ($(findstring libsorder.make,$(shell find $(ADDONS_BIN_LIBS_DIRS) -name libsorder.make 2> /dev/null)),libsorder.make)  
@@ -257,7 +257,10 @@  

Why should we go deeper into include directories anyway? I really don’t understand why going deeper into the directory chokes gcc but it does. In general libs provide an include directory to point the compiler to. If you go deeper into the include dir it should be done in the source not by telling the compiler to include the subdirs.

Any thoughts on this?

well we can’t rely on a forced directory structure for addons (yet), so I guess it’s best to search deeper into the dir tree. as wo why gcc chokes, no idea.
a refactor of the makefile structure is currently in the works, I hope this will make everything a bit smoother.

I hope it will be a bit smoother indeed :slight_smile:

Where’s this refactoring being done? I’d like to know what the thoughts on it are since I heavily rely on instructing others to use what OF dictates? Is something like cmake being considered? Also OF is already forcing a directory hierarchy even for addons so why this can’t be done…? Or am I missing something?

this is done in connection with work towards getting OF onto the raspberry pi. christopher baker and arturo castro are working on it. mostly it’s in this branch afaik: https://github.com/bakercp/openFrameworks/commits/feature-cross-platform-makefiles
the refactor is done so we get working makefiles on more/all platforms and make platform customization smoother. no cmake afaik.
well no, we don’t strictly force an addon structure, but we have defined a template for the addon structure (not “official” yet) which we’d like addons to adhere to, this will make trawling addons for info and makefile scanning etc much easier: https://github.com/benben/ofxAddonTemplate
of course this needs to be in place before we can point addon maintainers to it and ask them to update their addon structure. this will obviously take loong, with abandoned addons, infrequent maintenance, etc…

some libraries need different directories to be included, for most is just the include folder but others need to have in the search path include/json like in this case. the idea is to have an optional file for addons where you can specify things like this so addons that can be parsed automatically can be aided by this file, also it’ll include libraries from the system in linux so for libraries that are already in the distribution repos we don’t need to include them in the addons

I don’t think include/json is needed… just include. The headers are pointing like #include “json/json.h”.

Anyway… aren’t you guys reinventing the wheel here? I can imagine OF want stuff to be as user friendly as possible so the learning path is less steep than it can be. I don’t have any better ideas but being very strict about certain things can be helpful. I’ve been in many situations where addons were not following the right directory structure. But in other projects like Blender or Gamekit I’ve had the joys of working with cmake.

I just had to do:

  
cmake -G "CodeBlocks - Unix Makefiles" ../blender/  

To get me Codeblocks project files. Or even:

  
cmake -G "Eclipse CDT4 - Unix Makefiles" ../blender/  

for Eclipse.

For OSX and Windows there are UI’s to do so. The other alternative I come across often is Scons.

Although I can imagine you guys have already thought of these options :slight_smile:

if you run

pkg-config jsoncpp --cflags

it returns

-I/usr/include/jsoncpp

so that’s the standard for that library

and yes we’ve looked into other systems and the main problem is having to ask anyone to wants to do an addon to learn cmake or scons, so even if working with custom makefiles is slightly more complicated for us it makes it easier for anyone who wants to develop an addon

Ah I understand. I’m also finding it hard to get people to understand the whole c/c++ working pipeline. Cmake and Scons will only make it a longer pipeline and so complicate things even when they are built to make life easier.

I really like the libs.order, addons.make and config.make approach. It’s very easy to explain it to people and it keeps them away from makefile complication. However it only works for Linux. OSX is different and while it is very userfriendly people keep on starting from scratch once they did something wrong in Xcode. Windows is hardest although people understand it faster because they really have to do everything themselves. (Add include paths, add libs etc) Because of doing that they understand better. OSX is just include a folder and see how it goes. (I’m talking from what I see people doing)

I’ve been looking to see if I could get the Makefile work on Windows but I think Windows lacks all the shell commands like find, sed etc.

Btw the pkg-config includes are includes from your system. The distributions usually place the include folder in a sub-folder of /usr/include/. So /usr/include/jsoncpp is exactly the include folder you’ll find in the original source of the lib. So you still don’t want to recurse into that directory.

Rg,

Arnaud

a remake of the makefile system which works on more/all OSes is currently in the works: https://github.com/bakercp/openFrameworks/commits/feature-cross-platform-makefiles

Yes, I’ve been going through that remake. It’s great! Although the scope is only Linux variants and perhaps OSX. No Windows support, isn’t it?

not sure about that. macos definitely, i’d assume windows too, but better ask christopher baker or arturo.

I’m stuck on preprocessor issues again :’(
This time I’m trying to build an MongoDB addon using the C++ driver.
http://www.mongodb.org/pages/viewpage.action?pageId=133415

The code isn’t hard but once I include something of OF the preprocessors errors out. However this time I can’t seem to find a workaround. (yet) Traced it down to a single command:

  
  
g++ -c  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DOF_USING_GTK -DOF_USING_MPG123 -Wall -fexceptions -I. -I../../../z25-lib/unstable/openFrameworks/libs/glu/include -pthread -I/usr/include/GL -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -I../../../z25-lib/unstable/openFrameworks/libs/FreeImage/include -I../../../z25-lib/unstable/openFrameworks/libs/assimp/include -I../../../z25-lib/unstable/openFrameworks/libs/assimp/include/Compiler -I../../../z25-lib/unstable/openFrameworks/libs/cairo/include -I../../../z25-lib/unstable/openFrameworks/libs/cairo/include/cairo -I../../../z25-lib/unstable/openFrameworks/libs/cairo/include/pixman-1 -I../../../z25-lib/unstable/openFrameworks/libs/cairo/include/libpng15 -I../../../z25-lib/unstable/openFrameworks/libs/fmodex/include -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include/freetype2 -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include/freetype2/freetype -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include/freetype2/freetype/internal -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include/freetype2/freetype/internal/services -I../../../z25-lib/unstable/openFrameworks/libs/freetype/include/freetype2/freetype/config -I../../../z25-lib/unstable/openFrameworks/libs/kiss/include -I../../../z25-lib/unstable/openFrameworks/libs/portaudio/include -I../../../z25-lib/unstable/openFrameworks/libs/rtAudio/include -I../../../z25-lib/unstable/openFrameworks/libs/tess2/include -I../../../z25-lib/unstable/openFrameworks/libs/videoInput/include -I../../../z25-lib/unstable/openFrameworks/libs/poco/include -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/ -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/math -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/sound -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/3d -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/graphics -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/types -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/utils -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/gl -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/communication -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/.settings -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/video -I../../../z25-lib/unstable/openFrameworks/libs/openFrameworks/events -g3 -I../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs -I../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/src -I../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src  -MMD -MP -MFobj/x86_64Debug/src/main.d -MTobj/x86_64Debug/src/main.o -oobj/x86_64Debug/src/main.o -c src/main.cpp  
In file included from ../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/status.h:21:0,  
                 from ../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/util/assert_util.h:24,  
                 from ../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/pch.h:76,  
                 from ../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/client/dbclient.h:30,  
                 from ../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/src/ofxZ25Mongo.h:4,  
                 from src/testApp.h:4,  
                 from src/main.cpp:2:  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:36:13: error: expected identifier before numeric constant  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:36:13: error: expected ‘}’ before numeric constant  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:36:13: error: expected unqualified-id before numeric constant  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:63:40: error: ‘Error’ was not declared in this scope  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:70:16: error: ‘Error’ does not name a type  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:77:16: error: ‘Error’ does not name a type  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:79:36: error: ‘Error’ was not declared in this scope  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:82:1: error: expected declaration before ‘}’ token  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:63:28: warning: ‘mongo::errorString’ defined but not used [-Wunused-variable]  
../../../z25-lib/unstable/openFrameworks/addons/../../../../z25-lib-test/ofxZ25Mongo/libs/mongo-cxx-driver-nightly/src/mongo/base/error_codes.h:79:21: warning: ‘mongo::isNetworkError’ defined but not used [-Wunused-variable]  
  

main.cpp looks like this:

  
#include "ofMain.h"  
#include "testApp.h"  
  

It’s not doing anything but include ofMain.h and testApp.h.
testApp.h looks like:

  
#pragma once  
  
#include "ofxZ25Mongo.h"  
  

ofxZ25Mongo.h looks like:

  
#pragma once  
#include <cstdlib>  
#include <iostream>  
#include "mongo/client/dbclient.h"  
  

If I comment #include “ofMain.h” in main.cpp it compiles fine. Ofcourse it’s not doing anything but I’m just trying to get past the preprocessor issue. Is it me or am I hitting some fundamental issue?

FWIW, I struggled through this today on the latest raspbian 2014-01-07. My solution was to install jsoncpp from apt, remove jsoncpp from the ofxJSON libs directory, and add -I/usr/include/jsoncpp to CPP_FLAGS and -ljsoncpp to LDFLAGS in config.make.

Worked great with the version of ofxJSON (rev: 7fb21be737) fromh ttps://github.com/jefftimesten/ofxJSON

I throughly recommend @bakercp’s well-maintained ofxJSON fork which directs the user to install the * libjsoncpp-dev* package and works out of-the-box with Linux on ARM (and other platforms too!).

1 Like