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

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Neo
Just popping in
Just popping in
Posts: 13
Joined: Sat Mar 30, 2013 16:49

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

Postby Neo » Thu Jan 21, 2016 07:14

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:
Last edited by Neo on Tue Feb 09, 2016 03:19, edited 1 time in total.

iceiceice
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Thu Jul 09, 2015 10:20

Re: LuaScript module doesn't work on linux.

Postby iceiceice » Thu Jan 21, 2016 18:08

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.)

Neo
Just popping in
Just popping in
Posts: 13
Joined: Sat Mar 30, 2013 16:49

Re: LuaScript module doesn't work on linux.

Postby Neo » Thu Jan 21, 2016 19:11

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

Neo
Just popping in
Just popping in
Posts: 13
Joined: Sat Mar 30, 2013 16:49

Re: LuaScript module doesn't work on linux.

Postby Neo » Fri Jan 22, 2016 01:37

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?

User avatar
Ident
CEGUI Team
Posts: 1892
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: LuaScript module doesn't work on linux.

Postby Ident » Mon Jan 25, 2016 07:28

Did you go through the entire docu? http://static.cegui.org.uk/docs/0.8.4/

You might have forgotten to inject input events.
CrazyEddie: "I don't like GUIs"

Neo
Just popping in
Just popping in
Posts: 13
Joined: Sat Mar 30, 2013 16:49

Re: LuaScript module doesn't work on linux.

Postby Neo » Tue Feb 09, 2016 03:21

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 2 guests