Luajit: compiling bytecode to object format

The Luajit manual on the -b option says:

The type of the output file is automatically determined from the extension of the output file name:

  • c - source C file, exported bytecode data.
  • h is the header file C, static bytecode data.
  • obj or o - object file, exported bytecode data (depends on OS and architecture).
  • raw or any other extension is the source bytecode file (portable).

What does it mean to compile it into an object file? I know that it creates a file that can then be linked to other object files created from C or C ++ code.

But how does it work? How to use the generated object file from another C code? And in what situation will you do this?

+4
source share
1 answer

Embeds the bytecode for the module into a constant array.

If you then export this array from an executable or to a shared library, require will be able to find it there (and therefore no need to look for the source .lua file.)

+3
source

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


All Articles