Window
不想手动编译也可以直接去下载我编译的5.3.5版本
首先得下载GCC编译器,并且把GCC编译器的路径加入到系统变量的Path里面去,本人因为安装的有CodeBlocks,所以直接使用了CodeBlocks的GCC编译器,如果要下载GCC编译器可以去MinGW下载详细安装可参考其余教程。
本人的GCC编译器路径:
然后下载Lua源码:地址
下载后解压到一个目录->这个目录会作为工作目录
这个工作目录下你会看到你的lua-版本号的一个文件夹,比如我的:
然后现在在这个工作目录下创建一个文本文件:build.cmd
编辑内容:
@echo off
:: ========================
:: file build.cmd
:: ========================
setlocal
:: you may change the following variable's value
:: ~~调整你的版本号,你的版本是多少就改为多少,和你的工作目录下的文件夹名的版本相同~~
set lua_version=5.3.5
set work_dir=%~dp0
echo %work_dir%
:: Removes trailing backslash
:: to enhance readability in the following steps
set work_dir=%work_dir:~0,-1%
set lua_install_dir=%work_dir%\lua
::~~把下面的编译器的目录改为刚刚下载的GCC的目录,删掉这些中文~~
set compiler_bin_dir=~~D:\CodeBlocks\MinGW\bin(你的编译器目录)~~
set lua_build_dir=%work_dir%\lua-%lua_version%
set path=%compiler_bin_dir%;%path%
cd /D %lua_build_dir%
mingw32-make PLAT=mingw
echo.
echo **** COMPILATION TERMINATED ****
echo.
echo **** BUILDING BINARY DISTRIBUTION ****
echo.
:: create a clean "binary" installation
mkdir %lua_install_dir%
mkdir %lua_install_dir%\doc
mkdir %lua_install_dir%\bin
mkdir %lua_install_dir%\include
copy %lua_build_dir%\doc\*.* %lua_install_dir%\doc\*.*
copy %lua_build_dir%\src\*.exe %lua_install_dir%\bin\*.*
copy %lua_build_dir%\src\*.dll %lua_install_dir%\bin\*.*
copy %lua_build_dir%\src\luaconf.h %lua_install_dir%\include\*.*
copy %lua_build_dir%\src\lua.h %lua_install_dir%\include\*.*
copy %lua_build_dir%\src\lualib.h %lua_install_dir%\include\*.*
copy %lua_build_dir%\src\lauxlib.h %lua_install_dir%\include\*.*
copy %lua_build_dir%\src\lua.hpp %lua_install_dir%\include\*.*
echo.
echo **** BINARY DISTRIBUTION BUILT ****
echo.
%lua_install_dir%\bin\lua.exe -e"print [[Hello!]];print[[Simple Lua test successful!!!]]"
echo.
pause
然后点击运行即可,记住要按照要求修改,然后删掉中文,
然后就成功编译独立解释器,把解释器加入到Path变量中即可在控制台运行Lua