Page 1 of 1

[Solved]LuaScript module doesn't work on linux.

Posted: Thu Jan 21, 2016 07:14
by Neo
Hello all! I decided to use script to accelerating game development, so lua is introduced to my game.

However, to my disappointment, the lua module for CEGUI always give me Segmentation fault every time when it tries to run lua function, such as lua_call and scriptmodule::createbindings (which invoke tolua++ to run lua).

I have successfully compiled the lua script module library. And script module even crashes when initializing. Like the code in sample 8:

Code: Select all

LuaScriptModule& scriptmod(LuaScriptModule::create());

Even this line will trigger errors. But this time, error is Arithmetic exception in luaC_step () , probably occurred in lua_call in the constructor of script module. But when i copy those code out and run them in my program, they works fine. That's weird.

And the then function setScriptmodule() will trigger Segmentation fault when it tries to call binding function. (Apparently every attempt to run lua inside module)

By the way, 'i specify the library and headers for lua5.1 and tolua++5.1 in my program, otherwise I'll get link error in CEGUI lua module, all the lua calls works fine outside the CEGUI.

Any advice? I stack on this problem for a whole day and still can't use CEGUILuaScriptmodule (it seems sample doesn't work either, I just ignored it before). Thanks. :oops:

Re: LuaScript module doesn't work on linux.

Posted: Thu Jan 21, 2016 18:08
by iceiceice
Hi,

- What version of CEGUI are you using?
- Are you creating the CEGUI system before creating the CEGUI lua script module? I think that might be needed.
- Can you post a backtrace, like from gdb?
- Can you post a minimal example to reproduce the crash? Like, a program with 3 lines in

Code: Select all

 int main() { ... }
that you think shouldn't crash?
- Did you definitely enable the lua script module building when you built CEGUI with cmake (assuming you are using cmake?) I think that is also needed. (But I would imagine you would get link errors if you didn't do it... You might not though depending how you have it set up.)

Re: LuaScript module doesn't work on linux.

Posted: Thu Jan 21, 2016 19:11
by Neo
Thanks iceiceice,
I checked my code, it seems i try to set up script module before bootstrap CEGUI system, my bad.

But segfault still exists
gdb backtrace:

Code: Select all

#0  0x00007ffff67ea8a6 in luaD_throw ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#1  0x00007ffff67eac4d in luaD_growstack ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#2  0x00007ffff67eb268 in luaD_precall ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#3  0x00007ffff67eb520 in luaD_call ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#4  0x00007ffff67e8dbb in lua_callk ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#5  0x00007ffff671ca56 in CEGUI::LuaScriptModule::LuaScriptModule(lua_State*)
    () from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#6  0x00007ffff671eb41 in CEGUI::LuaScriptModule::create(lua_State*) ()
   from /usr/local/lib/libCEGUILuaScriptModule-0.so.2
#7  0x0000000000404382 in main (argc=1, argv=0x7fffffffde18)
    at ../src/game/Application.cpp:49


the code to repreduce crash:

Code: Select all

int main(int argc, char*argv[]) {

   irr::createDevice(video::EDT_OPENGL,core::dimension2d<u32>(800, 600),16, false, true, false,0);
   CEGUI::OpenGLRenderer::bootstrapSystem();
   using namespace CEGUI;

       LuaScriptModule& scriptmod(LuaScriptModule::create());

       System::getSingleton().setScriptingModule(&scriptmod);

   return 0;
}


CEGUI version : 0.8.4

Re: LuaScript module doesn't work on linux.

Posted: Fri Jan 22, 2016 01:37
by Neo
OK, I solved it!
The problem is when building lua script module, cmake automatically link the liblua.a under the /usr/local/lib, which is the lib of lua 5.3
So I change it manually to lua5.1 shared library directory, and everything works.

However, when I try to click the window, it just doesn't react to my actions. I can't move window, move scroll bars, click bottons, it looks like as if they are just a static image.
So what did I forget before subscribeEvent calls, or during the initialization?

Re: LuaScript module doesn't work on linux.

Posted: Mon Jan 25, 2016 07:28
by Ident
Did you go through the entire docu? http://static.cegui.org.uk/docs/0.8.4/

You might have forgotten to inject input events.

Re: LuaScript module doesn't work on linux.

Posted: Tue Feb 09, 2016 03:21
by Neo
Ident wrote:Did you go through the entire docu? http://static.cegui.org.uk/docs/0.8.4/

You might have forgotten to inject input events.


Yes,yes. Haven't worked on CEGUI for a year, I forget a lot of things.