Does the lua_load() C function work with LuaJIT pre-compiled bytecode?

944 Views Asked by At

I intend to embed LuaJIT into a program of mine that uses PhysFS to load... well, stuff. Both assets and Lua scripts.

So I thought, why not pre-compile my Lua scripts?

luajit -b test.lua test.raw

I know that when using normal vanilla Lua, the lua_load() C function works fine just fine with both human-readable scripts and bytecode made with luac. But what about LuaJIT? Does the same apply to LuaJIT? Does lua_load() work with precompiled LuaJIT bytecode?

1

There are 1 best solutions below

5
On

Quote from official site

The generated bytecode is portable and can be loaded on any architecture that LuaJIT supports, independent of word size or endianess. However the bytecode compatibility versions must match

More from same page

A file in raw bytecode format is auto-detected and can be loaded like any Lua source file. E.g. directly from the command line or with loadfile(), dofile() etc