exe化

1. 以下のサイトからlua-5.1.4のソースをダウンロードして展開

lua-5.1.4\srcフォルダに以下のファイルを作成

// main.c
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

int main()
{
    lua_State *L = lua_open();
    luaL_openlibs(L);
    int top = lua_gettop(L);
    int ret = luaL_dofile(L, "main.lua");
    if (ret != 0) {
        printf("error: %s\n", lua_tostring(L, -1));
        return 1;
    }
    lua_settop(L, top);
    lua_close(L);

    return 0;
}


2. main.exeを以下のコマンドによりビルド
lua-5.1.4\srcフォルダで以下のコマンドを実行。

> rename lua.c lua.c_
> rename luac.c luac.c_
> gcc -o main.exe *.c


3. 以下のサイトからsrluaのバイナリをダウンロードして展開


4. target.exeのビルド
srlua\Releaseフォルダにmain.exeをコピー
実行したいスクリプトmain.luaを作成
以下のコマンドを実行

> glue.exe main.exe main.lua target.exe

これで、target.exe単体で実行可能なファイルが出来る。