bad constant in precompiled chunk while executing

classic Classic list List threaded Threaded
5 messages Options
kapsky kapsky
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

bad constant in precompiled chunk while executing

I get an error while trying to load bytecode. Script is simple:
print("lubie placki")

When executing this and every other script as bytecode:
char* lua_argv[] = { (char *)"lua", (char *)"/rom/lua3.luac", NULL };
        lua_main( 2, lua_argv );

I get message: "bad constant in precompiled chunk while executing"

This error came from function
static void LoadConstants(LoadState* S, Proto* f)

What can I do with it ? What does exactly mean ? Would be nice if will be a description in wiki about this kind of errors, what they mean.

Thanks in advance for replies !
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: bad constant in precompiled chunk while executing

Hi,

That generally means that the Lua file wasn't compiled to bytecode properly; for example, precompiling for little endian on a big endian architecture, or the other way around. Other such issues are possible, like using invalid data types when precompiling. See for example https://github.com/elua/elua/blob/master/build_data.lua#L54 for a list of cross-compilation data.

Best,
Bogdan
kapsky kapsky
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: bad constant in precompiled chunk while executing

Thanks for reply.
How to proper compile it ? In http://www.eluaproject.net/doc/v0.9/en_using.html#cross is written that I should use
./luac -ccn float 64 -cce little -o <script.luac> -s <script.lua>
 option. But when I try to compile it I get
 luac: unrecognized option '-ccn'
In available options are not -ccn and -cce.
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: bad constant in precompiled chunk while executing

You're probably using the standard 'luac'. Cross-compilation requires a special luac that you need to build locally (the documentation talks about this). Try running 'lua cross-lua.lua', this should build the cross compiler locally.
kapsky kapsky
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: bad constant in precompiled chunk while executing

Yes you have right. Probably I was using some luac from PATH instead of generated by cross-lua.lua. Now everything works.

Thank you !
Loading...