Can the bytecode created by luac be used on computers without the Lua library?

If I compile a regular .lua file with luac , is it possible to run the result without a Lua library or interpreter?

+6
source share
2 answers

Not. You can run it on a Lua version that was built without a compiler, but you still need a Lua interpreter to execute the code.

By the way, the compiled Lua bytecode also depends on the machine; those. you cannot compile one architecture and then run this output on another architecture if you do not understand the subtleties (essence, type sizes, etc.).

+7
source

If your code does not use any tool with dynamic loading (these are loadstring, loadfile, require, etc.), you can deprive the Lua library only to the virtual machine, because some compiler emits the code that will run on this virtual machine, It can easily reduce Lua already small size to 1/3 of the original.

However, since this is NOT native binary for any existing architecture, you still CANNOT run it directly without the help of a virtual machine.

+1
source

Source: https://habr.com/ru/post/912276/


All Articles