Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

luac.out: incompatible precompiled chunk

Tags:

macos

lua

luac

I used luac to compile my lua code. The luac version is 5.2.2, and my app native lua is 5.2.2.

My lua code

function hello()
    print("hello test luac ")
end

hello()

The precompiled code:

1b4c 7561 5200 0104 0804 0800 1993 0d0a
1a0a 0000 0000 0000 0000 0001 0205 0000
0025 0000 0008 0000 8006 0040 001d 4080
001f 0080 0001 0000 0004 0600 0000 0000
0000 6865 6c6c 6f00 0100 0000 0100 0000
0300 0000 0000 0204 0000 0006 0040 0041
4000 001d 4000 011f 0080 0002 0000 0004
0600 0000 0000 0000 7072 696e 7400 0411
0000 0000 0000 0068 656c 6c6f 2074 6573
7420 6c75 6163 2000 0000 0000 0100 0000
0000 5b00 0000 0000 0000 402f 5573 6572
732f 7269 6b2f 4465 736b 746f 702f 6361
7264 4761 6d65 2f63 6c69 656e 742f 4361
7264 5265 6c65 6173 652f 7376 6e2e 7368
2f41 7373 6574 732f 5374 7265 616d 696e
6741 7373 6574 732f 4c75 612f 5465 7374
2e6c 7561 0004 0000 0002 0000 0002 0000
0002 0000 0003 0000 0000 0000 0001 0000
0005 0000 0000 0000 005f 454e 5600 0100
0000 0100 5b00 0000 0000 0000 402f 5573
6572 732f 7269 6b2f 4465 736b 746f 702f
6361 7264 4761 6d65 2f63 6c69 656e 742f
4361 7264 5265 6c65 6173 652f 7376 6e2e
7368 2f41 7373 6574 732f 5374 7265 616d
696e 6741 7373 6574 732f 4c75 612f 5465
7374 2e6c 7561 0005 0000 0003 0000 0001
0000 0005 0000 0005 0000 0005 0000 0000
0000 0001 0000 0005 0000 0000 0000 005f
454e 5600 

When I dofile the precompiled code I got error like this:

LuaScriptException: /Users/rik/Desktop/cardGame/client/CardRelease/svn.sh/Assets/StreamingAssets/Lua/luac.out: incompatible precompiled chunk
NLua.Lua.ThrowExceptionFromError (Int32 oldTop)
NLua.Lua.DoFile (System.String fileName)

How can i use precompiled lua code in my app?

like image 549
ricky pu Avatar asked Oct 21 '22 22:10

ricky pu


1 Answers

The platforms where you've precompiled the Lua script and where you're trying to load it are incompatible in the sense that they have different word sizes or endianness. Lua bytecode is not portable across architectures.

like image 125
lhf Avatar answered Oct 27 '22 18:10

lhf