Have you ever wanted to compile your Lua scripts into Windows executables? Having trouble deploying Lua programs on other computers? Here's a quick and easy way to turn your Lua scripts into executables.
rtc, an open source Lua to exe compiler
rtcis a simple command line tool to build standalone executables from your Lua scripts. A GUI front end is available for those who are resistant to the console.
rtccan be downloaded on theGitHub project homepage,and available for x86 and x64 Windows platforms.
Once downloaded, put the content of the ZIP archive on your hard disk and make sure it's available on your system PATH.
Let's build our first executable
Create a simplehello.lua
file containing this script:
print("Hello World!")
io.stdin:read("*l")
Now, open a console or terminal prompt, go to the folder where you have saved the filehello.lua
and enter the following command:
rtc hello.lua
And voila!rtc
should have produced an executable namedhello.exe
.You can run it like any other executable.
Static executables with rtc
By default,rtc
creates dynamic executables, meaning the Lua VM is in the librarylua54.dll
and its needed to run any program built withrtc
(this dependency can be found along your executable or in your system PATH).
If you want to get rid of this library dependency, you can tellrtc
to build a static executable with the-s
option:
rtc-shello.lua
Thehello.exe
file will be fatter, as it includes now the Lua VM. But be careful with those static executables, as it is strongly discouraged to require for Lua binary modules (may lead to crash). Use this option only if your program don't need any Lua binary module.
What's next?
This tutorial shows basic usage ofrtc
.But there is more functionnalities available, like generating Desktop executables, changing default executable icon, embedding content...
Please read thertc documentationfor more on this.