脚本来源:,http://demon.tw/software/compile-lua-with-tcc.html 版权归原作者所有
使用方法:
1.下载编译器,本文解压目录:C:\Program Files\tcc,
2.下载源码,本文解压到D:\lua-5.3.4
3.然后把这个脚本放到D:\lua-5.3.4目录运行
编译5.3.4过程中使用博客中的脚本会出现:tcc: error: undefined symbol 'luaopen_utf8'
原因是在链接/生成lua.exe/luac.exe过程中缺失了luaopen_utf8声明,声明在lutf8lib.c中,编译时把这个文件带入即可
@echo offrem Author: Demonrem Date: 2012/6/2rem Website: http://demon.twset INSTALL_TOP=D:\lua-5.3.4set INSTALL_BIN=%INSTALL_TOP%\binset INSTALL_INC=%INSTALL_TOP%\includeset INSTALL_LIB=%INSTALL_TOP%\libset PATH=C:\Program Files\tcc;%PATH%if not exist %INSTALL_BIN% mkdir %INSTALL_BIN%if not exist %INSTALL_INC% mkdir %INSTALL_INC%if not exist %INSTALL_LIB% mkdir %INSTALL_LIB%cd srctcc -r -o liblua.a lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.crem 兼容5.3.4版本处理type linit.c|find /i "luaopen_utf8">nulif "%errorlevel%"=="0" ( tcc -o lua.exe liblua.a lua.c lutf8lib.c tcc -o luac.exe liblua.a luac.c lutf8lib.c) else ( tcc -o lua.exe liblua.a lua.c tcc -o luac.exe liblua.a luac.c)>nul copy lua.exe %INSTALL_BIN%>nul copy luac.exe %INSTALL_BIN%>nul copy liblua.a %INSTALL_LIB%for %%i in (lua.h luaconf.h lualib.h lauxlib.h lua.hpp) do (>nul copy %%i %INSTALL_INC%)%INSTALL_BIN%\lua.exe -i