I finally got it to work to make a fat static library for luabind that works on ppc and intel mac but I am experiencing some really weird errors when usind it with OF. If I include #include <luabind/luabind.hpp> in the testApp.h where you would usually put it in it throws some weird template errors (38 of those):
luabind/luabind/class.hpp:1029: error: expected identifier before numeric constant
luabind/luabind/class.hpp:1029: error: expected `>’ before numeric constant
luabind/luabind/class.hpp:1030: error: ‘B1’ was not declared in this scope
luabind/luabind/class.hpp:1030: error: ‘B2’ was not declared in this scope
luabind/luabind/class.hpp:1030: error: ‘B3’ was not declared in this scope
luabind/luabind/class.hpp:1030: error: type/value mismatch at argument 1 in template parameter list for ‘template<class A0, class A1, class A2, class A3> struct luabind::bases’
luabind/luabind/class.hpp:1030: error: expected a type, got ‘0’
luabind/luabind/class.hpp:1030: error: template argument 2 is invalid
luabind/luabind/class.hpp:1030: error: template argument 3 is invalid
luabind/luabind/class.hpp:1030: error: template argument 4 is invalid
luabind/luabind/class.hpp:1030: error: template argument 1 is invalid
luabind/luabind/class.hpp:1032: error: type/value mismatch at argument 1 in template parameter list for ‘template struct luabind::detail::type_’
luabind/luabind/class.hpp:1032: error: expected a type, got ‘0’
luabind/luabind/class.hpp:1032: error: ‘B1’ was not declared in this scope
luabind/luabind/class.hpp:1032: error: template argument 1 is invalid
luabind/luabind/class.hpp:1032: error: ‘B2’ was not declared in this scope
luabind/luabind/class.hpp:1032: error: template argument 1 is invalid
luabind/luabind/class.hpp:1032: error: ‘B3’ was not declared in this scope
luabind/luabind/class.hpp:1032: error: template argument 1 is invalid
the weird thing is, if I include it in the testApp.cpp before I include testApp.h eversthing works fine, only if I include it within testApp.h or after testApp.h those errors ocur. Any ideas what could cause that?
B##n is a macro construct that chains B to the content of n.
so if you call LUABIND_GEN_BASE_INFO(z, n, text) with n = labla
then B##n will expand to Blabla.
yes, thats just some boost preprocessor stuff, where function templates get generated. I still don’t get how this can cause errors if I include it in testApp.h, but wors fine if I include it in testApp.cpp before testApp.h.
I tried the same thing in ubuntu today and its the same problem, so its not mac specific but somehow a general problem with luabind and of. the workaround (including luabind at the beginning of testApp.cpp) works, so its no big deal, but kind of ugly
does anybody have an idea about to fix it? I am currently trying to build a small framework around luabind and its kind of like a pain to do that if I cant include luabind in testApp.h (since I also cant include any files there that use luabind.hpp) so weird…
usually when very strange things happen it’s because of headers that get included twice. make sure you don’t.
can you post testApp.h and testApp.cpp? otherwise it’s just guessing.
i think there’s a way to view the output of the preprocessor. there’s ought to be some compiler flag so that it outputs the code after the preprocessor only.
how would you do that? i have actually no clue about codeblocks and I am just getting started with it.
I am sure now that the problem is the #include <termios.h> include in ofSerial.h, since everything compiles without it. an optimal way would be to uninclude after ofSerial but I guess thats not possible…any ideas on that?
a simple workaround would be to include all the files related to ofSerial manually after the luabind stuff and delete the inclusion from ofMain.h thats what I do right now. Would be awesome though to get it fixed so i could maybe release the stuff I am working on as an easy to use addon.
i don’t know anything about codeblocks, the only advice i can give is to look in the manual pages of gcc (the c-compiler are using most likely). to do that open a terminal window in linux and type man gcc. then look for the compiler switch. there should be a way to add that to your settings in codeblocks but i don’t know how.
but maybe it’s too much. there should be an easier way to solve your problem but without the full code it’s no use trying to solve it-
I’m trying to build lua+luabind in OF and getting similar problems with the check and nil macro defines.
From reading this (http://boost-geometry.203548.n3.nabble.com/problems-with-Boost-Geometry-Xcode-compile-td437866.html), I found you can disable the old macro names in AssertMacros.h by setting __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 in the C flags. This gets lua to build fine but luabind still fails on: ‘Macro “check” passed 2 arguments, but takes just 1’, even when I use the undef hack.
As a control, I made a non-OF test project and lua+luabind build and work fine, no problems.
Any ideas? I’m banging my head against the wall. I can put up the code+project later today … (ofxLua)
I needed to add -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 to *both* the C flags and CPP flags. It seems the define was not being set for the luabind C++ sources when compiling, so the check macro from AssertHeaders.h was still being set, annoying.
Now that the check macro conflicts were gone, I had conflicts from the nil macro in MacTypes.h. Again, the undef hack doesn’t seem to work. I then decided to spilt the lua and luabind code out of the single target and into 2 static libs.
lua builds fine in a static lib but luabind now throws a weird template error. It seems to be a namespaace problem as detailed here (http://osdir.com/ml/lang.lua.bind.user/2007-06/msg00013.html). Adding luabind::detail:: before each ambiguous function call fixed it.
Great, so now I can compile and actually *do* something. Ideally, I’d prefer a single target without the static libs (makes addon usage easier for newbies), but it is working at least.