I get tons of errors after I compile a lua file into a stand-alone program (i.e. exe) with srlua.
Always anything in the "require()" it cannot find later and the program will simply not run.
Is there a way 开发者_开发问答to solve this and so the program will run properly?
Thanks.
When you execute require
, the default methods scan directories based on the location of lua.exe
. srLua seems to not handle dependencies. Perhaps you should use Lua Built-In Program instead. The project seems to be abandoned, but it did have a release in 2010, so it's mostly recent.
I have had good results from using Squish recently to collect a bunch of Lua modules and several related scripts together so that they could be packaged in a single exe along with their host app.
I did have to make some tweaks to build and use it in Windows, but they were all obvious extensions or translations of the Unix-centric existing source kit. Squish itself is written in pure Lua, and building it applies squish to itself to generate a single self-contained script file for use with the normal Lua interpreter.
In addition to handling dependent modules, it can also compile and/or compress the code for even smaller output.
If you are working with the stock Lua interpreter, then using Squish to get a single file and srlua to package it with the interpreter is probably a good combination.
精彩评论