Luajit: compiling bytecode into object format

最后都变了- 提交于 2019-12-10 17:22:03

问题


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?


回答1:


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.)



来源:https://stackoverflow.com/questions/16865040/luajit-compiling-bytecode-into-object-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!