The Luajit manual about the -b option says:
The output file type is auto-detected from the extension of the output file name:
- c — C source file, exported bytecode data.
- h — C header file, static bytecode data.
- obj or o — Object file, exported bytecode data (OS- and architecture-specific).
- raw or any other extension — Raw bytecode file (portable).
What does it mean to compile it to object file? I know it produces a file which then can be linked with other object files generated from C or C++ code.
But how does this work? How would one use the generated object file from other C code? And in which situation would you do it?
It embeds the bytecode for a module into a constant array.
If you then export this array from the executable or a shared library,
require
will be able to find it there (and thus not need to search for the.lua
source file.)