Windows Lua 到可执行文件 [英] Windows Lua to executable

查看:39
本文介绍了Windows Lua 到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Lua 程序(用 Lua 5.1 编写).我在 Windows 7 上,试图将其转换为可执行文件.到目前为止没有运气.我在这里阅读了其他建议使用 srlua 来执行此操作的帖子,所以我已经下载了它,但我不知道下一步该怎么做.我安装了 cygwin,因为我知道这是必要的,但我不知道如何使用 srlua 将 lua 文件转换为可执行文件.任何帮助将不胜感激.

hi I have a Lua program (written in Lua 5.1). I'm on Windows 7, trying to convert it to an executable. No luck so far. I've read other posts here that suggested using srlua to do this so I've downloaded it but I'm on a loss as to what to do next. I installed cygwin as I understand it's necessary but I don't know how to use srlua to convert a lua file into an executable. Any help will be appreciated.

推荐答案

srlua 仅作为源代码分发,因此您必须先编译它(参见 这个答案 获取免费 C 编译器的建议).

srlua is distributed as source only, so you have to compile it first (see this answer for suggestions on getting a free C compiler).

顺便说一句,Cygwin 根本没有必要.上述链接将引导您安装 TDM-GCC,这是 GCC 编译器的 Windows 端口,它将创建仅依赖于 Windows 默认系统库的可执行文件.

BTW, Cygwin is not necessary at all. The aforementioned link will lead you to instructions to install TDM-GCC, a Windows port of GCC compiler that will create executable files which only depend on Windows default system libraries.

一旦有了 C 编译器并编译了 srlua,您将拥有两个可执行文件 glue.exesrlua.exe.后者只是一个存根,由 srlua.exe 用来通过将它与您的 Lua 脚本连接来生成最终的可执行文件.

Once you have a C compiler in place and you have compiled srlua, you will have two executable files glue.exe and srlua.exe. This latter is only a stub, used by srlua.exe to generate the final executable by joining it with your Lua script.

假设你的脚本是 myscript.lua 并且你想创建一个名为 myexe.exe 的可执行文件,你必须从命令行如下:

Assuming your script is myscript.lua and you want to create an executable named myexe.exe you must invoke glue.exe from the command line as follows:

 glue.exe srlua.exe myscript.lua myexe.exe

我假设所有相关文件都放在同一目录中,而您从命令行切换到该目录.

I assumed that all the relevant files are placed in the same directory and you changed to that directory from the command line.

附录:我只是仔细检查了官方下载页面的 srlua 并且我看到还有一个已经为 Windows 编译的二进制文件的包.所以你可以跳过源代码部分的所有编译,只需下载并解压this.

Addendum: I just double checked the official download page for srlua and I saw there is also a package with already compiled binaries for Windows. So you could skip all the compilation from source part and simply download and unpack this.

二进制文件位于存档内的 Release 子目录中.请注意,这些仅适用于 Lua 5.1,因此如果您的脚本使用 Lua 5.2 的功能,您必须遵循我最初的建议并从源代码编译.

The binaries are in the Release subdirectory inside the archive. Note that these are for Lua 5.1 only, so if your script uses features of Lua 5.2 you must follow my initial advice and compile from source.

这篇关于Windows Lua 到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆