简体   繁体   English

Windows Lua可执行

[英]Windows Lua to executable

hi I have a Lua program (written in Lua 5.1). 嗨,我有一个Lua程序(用Lua 5.1编写)。 I'm on Windows 7, trying to convert it to an executable. 我在Windows 7上,尝试将其转换为可执行文件。 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. 我已经阅读了其他帖子,建议使用srlua这样做,所以我已经下载了它,但我不知道下一步该做什么。 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. 我安装了cygwin,因为我知道它是必要的,但我不知道如何使用srlua将lua文件转换为可执行文件。 Any help will be appreciated. 任何帮助将不胜感激。

srlua is distributed as source only, so you have to compile it first (see this answer for suggestions on getting a free C compiler). srlua仅作为源分发,因此您必须首先编译它(有关获取免费C编译器的建议,请参阅此答案 )。

BTW, Cygwin is not necessary at all. 顺便说一句,Cygwin根本就没有必要。 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. 上述链接将引导您安装TDM-GCC的说明,TDM-GCC是GCC编译器的Windows端口,它将创建仅依赖于Windows默认系统库的可执行文件。

Once you have a C compiler in place and you have compiled srlua, you will have two executable files glue.exe and srlua.exe . 一旦你有一个C编译器并且你已经编译了srlua,你将有两个可执行文件glue.exesrlua.exe This latter is only a stub, used by srlua.exe to generate the final executable by joining it with your Lua script. 后者只是一个存根,由srlua.exe用于通过将其与Lua脚本连接来生成最终可执行文件。

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: 假设您的脚本是myscript.lua并且您想要创建名为myexe.exe的可执行文件,则必须从命令行调用glue.exe ,如下所示:

 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. 我假设所有相关文件都放在同一目录中,并从命令行更改为该目录。

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. 附录:我只是仔细检查了srlua的官方下载页面,我看到还有一个已经编译过的Windows二进制文件包。 So you could skip all the compilation from source part and simply download and unpack this . 所以,你可以跳过所有从源代码部分的编译和只需下载并解压这个

The binaries are in the Release subdirectory inside the archive. 二进制文件位于存档内的Release子目录中。 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. 请注意,这些仅适用于Lua 5.1,因此如果您的脚本使用Lua 5.2的功能,则必须遵循我的初始建议并从源代码编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM