0

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 Answers1

0

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

moteus
  • 2,187
  • 1
  • 13
  • 16
  • Both `loadfile` and `dofile` are **LuaJit** functions, not **C** functions. OP wants to call LuaJit bytecode from **C**. – MarkWeston Sep 26 '17 at 10:20
  • So? I assumes he uses LuaJIT library for that. Of course it will not work for different implementation of Lua. – moteus Sep 26 '17 at 10:23
  • Correct me if I'm wrong, but the page you're linking to talks about the LuaJit interpreter. It doesn't say anything about running LuaJit bytecode using the C API. And I found nothing that indicates that `lua_load`, using the LuaJit C API, will correctly load LuaJit bytecode. – MarkWeston Sep 26 '17 at 10:25
  • How do you think `loadstring` implemented? This is just lib function which implemented on top of Lua C API. – moteus Sep 26 '17 at 11:34
  • Confirmed to work. – Stephanus Tavilrond Sep 26 '17 at 13:58