danomatika / loaf

loaf: lua, osc, and openFrameworks
http://danomatika.com/code/loaf
GNU General Public License v3.0
53 stars 4 forks source link

Building on Linux #2

Closed keithohara closed 6 years ago

keithohara commented 6 years ago

Long time Processing & Lua user, but new to OF; this project looks great!

When trying to build loaf on Ubuntu 14.04 (gcc-4.9), I ran into this error:

In file included from /usr/include/X11/Xlib.h:44:0,
                 from /usr/include/GL/glx.h:30,
                 from OF/libs/openFrameworks/utils/ofConstants.h:184,
                 from OF/libs/openFrameworks/utils/ofFileUtils.h:3,
                 from loaf-1.3.0/src/CommandLine.cpp:26:
loaf-1.3.0/src/options/optionparser.h:889:20: error: expected unqualified-id before numeric constant
   static ArgStatus None(const Option&, bool)
                    ^
In file included from loaf-1.3.0/src/CommandLine.cpp:30:0:
loaf-1.3.0/src/options/Options.h:365:34: error: expected unqualified-id before ‘const’
    static option::ArgStatus Bool(const option::Option& option, bool msg) {
                                  ^
loaf-1.3.0/src/options/Options.h:365:34: error: expected ‘)’ before ‘const’
loaf-1.3.0/src/CommandLine.cpp:113:1: error: expected ‘}’ at end of input
 }
 ^

None and Bool clash with preprocessor macros from X.h so my workaround was to change CommandLine.cpp:

#include "ofFileUtils.h"
#undef None
#undef Bool
#include "ofLog.h"
#include "Options.h"
danomatika commented 6 years ago

Thanks for building on Linux, I tried to structure the project so it would but haven't done it yet personally.

It seems strange they would clash as both of those types should be declared within a namespace. Following your suggestion, a quick fix might be:

#include "ofFileUtils.h"
#include "ofLog.h"
#ifdef TARGET_OS_LINUX
    // these are set by X.h and clash with optionsparser types
    #undef None
    #undef Bool
#endif
#include "Options.h"
danomatika commented 6 years ago

This should now be fixed with loaf 1.4.0