c++ - 与项目一起构建 Lua 脚本

标签 c++ lua

如何构建我的 C++ 项目以将所有 Lua 文件包含在一个可执行文件中?我不希望人们能够编辑 Lua 文件并改变游戏。

这可能吗,是否合乎道德?

最佳答案

使用 LuaJIT 的“embedded bytecode”特性:

To statically embed the bytecode of a module in your application, generate an object file and just link it with your application.

require() tries to load embedded bytecode data from exported symbols (in *.exe or lua51.dll on Windows) and from shared libraries in package.cpath.

例子:

luajit -b test.lua test.obj                 # Generate object file
# Link test.obj with your application and load it with require("test")

关于c++ - 与项目一起构建 Lua 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22885455/

相关文章:

c++ Singleton with map 原因 "violation reading location"

c++ - C/C++ 代码中函数的多重定义

c++ - Box2d - 从 body 获取夹具的宽度还是我应该尝试?

google-maps - 谷歌地图 'Implicit Positioning of the Map' 坏了?

lua - opengl应用程序中的交互式lua提示符

c++ - 哪个更好 : Function overriding or passing a function pointer for event handling

c++ - 在 ab 中调用函数(C/C++)的官方方法是什么?在 Linux 上每 1/100 秒?

interface - 简单的 WoW 界面插件不起作用(Lua)

c# - ANTLR - 为 AST 编写树语法

lua - 尝试将字符串与数字进行比较 - computercraft