Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding compilation order, compilation errors, and luabind due to base class undefined
    primarykey
    data
    text
    <p><strong>How do I trace my compliation order? (So that I may re-order it)</strong></p> <p>My issue: I'm running Visual Studio 2012 writing a C++ application. I binded a scripting system, Lua, to my project using <a href="http://www.rasterbar.com/products/luabind/docs.html" rel="nofollow noreferrer">LuaBind</a></p> <p>LuaBind hides away Lua stuff and figures out how to bind it to the Lua Language (or some magic)</p> <p>I can take an object, call a function on it, and pass in a C++ object to be given to the lua script function</p> <pre><code>// ScriptComponent.h class ScriptComponent : public Component { public: virtual void Initialize(); virtual void Update(); protected: luabind::object luaDataTable; Entity* mOwner; </code></pre> <p>-</p> <pre><code>// ScriptComponent.cpp void ScriptComponent::Initialize() { luabind::object compiledScript; luaL_loadfile(L, "myScript.lua"); luabind::object compiledScript(luabind::from_stack(L, -1)); luaDataTable = compiledScript(); lua_pop(L, 1); } void ScriptComponent::Update() { luaDataTable["run"](mOwner); // Compiler breaks here. // Note: if I remove mOwner from the mix (and in the script file) everything works and runs fine. } </code></pre> <p>Cool! But to get this to work, luabind needs to know what mOwner (Entity*) is and have ti defined. So, I define it in a different file:</p> <pre><code>// GameScriptingSystem.cpp using namespace luabind; module(inLuaState) [ class_&lt;GameObject&gt;("GameObject"), class_&lt;Entity, bases&lt;GameObject&gt; &gt;("Entity") .def("DebugGetName", &amp;Entity::DebugGetName) ]; </code></pre> <p>The flow looks something like this: <img src="https://i.stack.imgur.com/h4S3m.png" alt="enter image description here"></p> <p>The result:</p> <blockquote> <p>error C2504: 'Entity' : base class undefined</p> </blockquote> <p>Full error as requested:</p> <pre><code>... 2&gt; Component.cpp 2&gt; ScriptComponent.cpp 2&gt;boost/type_traits/is_polymorphic.hpp(46): error C2504: 'Entity' : base class undefined 2&gt; boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1&lt;T&gt;::d2' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; boost/type_traits/is_polymorphic.hpp(97) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1&lt;T&gt;' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; boost/type_traits/is_polymorphic.hpp(102) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp&lt;T&gt;' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; luabind/detail/make_instance.hpp(42) : see reference to class template instantiation 'boost::is_polymorphic&lt;T&gt;' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; luabind/detail/make_instance.hpp(74) : see reference to function template instantiation 'std::pair&lt;_Ty1,_Ty2&gt; luabind::detail::get_dynamic_class&lt;T&gt;(lua_State *,T *)' being compiled 2&gt; with 2&gt; [ 2&gt; _Ty1=luabind::detail::class_id, 2&gt; _Ty2=void *, 2&gt; T=Entity 2&gt; ] 2&gt; luabind/detail/policy.hpp(228) : see reference to function template instantiation 'void luabind::detail::make_instance&lt;T*&gt;(lua_State *,P)' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity, 2&gt; P=Entity * 2&gt; ] 2&gt; luabind/detail/convert_to_lua.hpp(87) : see reference to function template instantiation 'void luabind::detail::pointer_converter::apply&lt;Entity&gt;(lua_State *,T *)' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; luabind/object.hpp(1072) : see reference to function template instantiation 'void luabind::detail::convert_to_lua_p&lt;1,Entity*,Policies&gt;(lua_State *,const T &amp;,const Policies &amp;)' being compiled 2&gt; with 2&gt; [ 2&gt; Policies=luabind::detail::null_type, 2&gt; T=Entity * 2&gt; ] 2&gt; luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple&lt;Index&gt;::apply&lt;T0,boost::tuples::detail::map_tuple_to_cons&lt;boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;::type,luabind::detail::null_type&gt;(lua_State *,const boost::tuples::cons&lt;HT,TT&gt; &amp;,const Policies &amp;)' being compiled 2&gt; with 2&gt; [ 2&gt; Index=1, 2&gt; T0=Entity *const *, 2&gt; HT=Entity *const *, 2&gt; TT=boost::tuples::detail::map_tuple_to_cons&lt;boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;::type, 2&gt; Policies=luabind::detail::null_type 2&gt; ] 2&gt; luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple&lt;Index&gt;::apply&lt;T0,boost::tuples::detail::map_tuple_to_cons&lt;boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;::type,luabind::detail::null_type&gt;(lua_State *,const boost::tuples::cons&lt;HT,TT&gt; &amp;,const Policies &amp;)' being compiled 2&gt; with 2&gt; [ 2&gt; Index=1, 2&gt; T0=Entity *const *, 2&gt; HT=Entity *const *, 2&gt; TT=boost::tuples::detail::map_tuple_to_cons&lt;boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;::type, 2&gt; Policies=luabind::detail::null_type 2&gt; ] 2&gt; luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy&lt;ValueWrapper,Arguments&gt;::call&lt;luabind::detail::null_type&gt;(Policies *)' being compiled 2&gt; with 2&gt; [ 2&gt; ValueWrapper=luabind::adl::index_proxy&lt;luabind::adl::object&gt;, 2&gt; Arguments=boost::tuples::tuple&lt;Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;, 2&gt; Policies=luabind::detail::null_type 2&gt; ] 2&gt; luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy&lt;ValueWrapper,Arguments&gt;::call&lt;luabind::detail::null_type&gt;(Policies *)' being compiled 2&gt; with 2&gt; [ 2&gt; ValueWrapper=luabind::adl::index_proxy&lt;luabind::adl::object&gt;, 2&gt; Arguments=boost::tuples::tuple&lt;Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt;, 2&gt; Policies=luabind::detail::null_type 2&gt; ] 2&gt; luabind/object.hpp(1110) : while compiling class template member function 'luabind::adl::call_proxy&lt;ValueWrapper,Arguments&gt;::~call_proxy(void)' 2&gt; with 2&gt; [ 2&gt; ValueWrapper=luabind::adl::index_proxy&lt;luabind::adl::object&gt;, 2&gt; Arguments=boost::tuples::tuple&lt;Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt; 2&gt; ] 2&gt; ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to function template instantiation 'luabind::adl::call_proxy&lt;ValueWrapper,Arguments&gt;::~call_proxy(void)' being compiled 2&gt; with 2&gt; [ 2&gt; ValueWrapper=luabind::adl::index_proxy&lt;luabind::adl::object&gt;, 2&gt; Arguments=boost::tuples::tuple&lt;Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt; 2&gt; ] 2&gt; ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to class template instantiation 'luabind::adl::call_proxy&lt;ValueWrapper,Arguments&gt;' being compiled 2&gt; with 2&gt; [ 2&gt; ValueWrapper=luabind::adl::index_proxy&lt;luabind::adl::object&gt;, 2&gt; Arguments=boost::tuples::tuple&lt;Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type&gt; 2&gt; ] 2&gt;boost/type_traits/is_polymorphic.hpp(34): error C2504: 'Entity' : base class undefined 2&gt; boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1&lt;T&gt;::d1' being compiled 2&gt; with 2&gt; [ 2&gt; T=Entity 2&gt; ] 2&gt; Map.cpp 2&gt; Generating Code... 2&gt; Compiling... 2&gt; GameScriptingSystem.cpp 2&gt; PoCToolsInterface.cpp .. </code></pre> <p>As far as I can tell, its due to the build order. My best guess is that Luabind does all this stuff at compiletime, and when I look at the compilation first, <strong>ScriptComponent is compiled first</strong>, <strong>GameScriptSystem is compiled after</strong>. When ScriptComponent builds, alll the luabind errors through. THEN after GameScriptSystem builds (which defines all the stuff LuaBind is complaining about)</p> <p>So:</p> <ul> <li><p>How do I track my build order? See what files are triggering build of others, so that I may re-arrange it to my liking? (its a big project, its not as easy as looking at it for 2 seconds)</p></li> <li><p>If you know luabind, am I right about this being the issue?</p></li> </ul> <p>Other data:</p> <pre><code>-- myScript.lua local Cat = {} local ticks = 0 function Cat.run(entity) ticks = ticks + 1 LOG(tostring(ticks)) LOG(entity:DebugGetName()) end return Cat </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload