Luajit:将字节码编译为对象格式 [英] Luajit: compiling bytecode into object format
问题描述
关于 -b 选项的Luajit手册说:
The Luajit manual about the -b option says:
从输出文件名的扩展名中自动检测到输出文件类型:
- c — C源文件,导出的字节码数据.
- h — C头文件,静态字节码数据.
- obj或o-目标文件,导出的字节码数据(特定于OS和体系结构).
- 原始或任何其他扩展名-原始字节码文件(便携式).
- 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).
将其编译为目标文件是什么意思?我知道它会生成一个文件,然后可以将其与从C或C ++代码生成的其他目标文件链接.
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.
但这如何工作?一个人将如何使用从其他C代码生成的目标文件?在哪种情况下您会这样做?
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.
如果您随后从可执行文件或共享库中导出此数组,则require
将能够在其中找到它(因此无需搜索.lua
源文件.)
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.)
这篇关于Luajit:将字节码编译为对象格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!