Creating standalone Lua executables

后端 未结 6 1367
天命终不由人
天命终不由人 2020-12-02 08:37

Is there an easy way to create standalone .exe files from Lua scripts? Basically this would involve linking the Lua interpreter and the scripts.

I believe it is poss

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 09:11

    Since you say '.exe' I'll assume you're looking for a Windows solution. One idea is to just append scripts to a prebuilt interpreter executable. It may or may not qualify as 'easy' in your book.

    The interpreter needs to be able to read itself, parse its header to determine where the regular .exe data ends (ie. where the script begins) and then hand off the remainder of the file to Lua.

    Other solutions don't require the interpreter to work as hard but do require more involved linking, whereas with this method, exeifying a script can be as simple as

    copy interpreter.exe+script.lua script.exe
    

提交回复
热议问题