我下载Lua v5.3.0和编译器以及Zip-7并将所有内容保存在C:\\gcc-install-lua
目录并打开记事本并写入此代码:
@echo off
:: ========================
:: file build.cmd
:: ========================
setlocal
:: you may change the following variable's value
:: to suit the downloaded version
set lua_version=5.3.0
set work_dir=%~dp0
:: Removes trailing backslash
:: to enhance readability in the following steps
set work_dir=%work_dir:~0,-1%
set lua_install_dir=%work_dir%\lua
set compiler_bin_dir=%work_dir%\tdm-gcc\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
在目录中另存为cmd文件,现在我想在commend行中运行build.cmd但是我在Cmd中给出了这个错误
在Lua文件中创建bin子目录后没有lua.exe文件,我怎么能修复它?
答案 0 :(得分:0)
此方法可能不适用于OP的情况,但构建Lua for Windows的最简单方法是使用Visual Studio(我假设您已经在PC上安装了它)。
您需要创建新文件luavs.bat
并填写内容(见下文)
cd /d full\path\to\lua-5.3.4
notepad luavs.bat
现在你的lua distrib文件夹应该如下所示:
lua-5.3.4
|___src
| |...
|___doc
| |...
|___Makefile
|___README
|___luavs.bat
您必须不是直接运行luavs.bat
,而是从Visual Studio命令提示符(在"所有程序""开始"菜单下)中搜索它。
在出现以下行之后:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>
输入以下命令:
cd /d full\path\to\lua-5.3.4
luavs.bat
mkdir C:\Lua
copy /y src\lua53.exe C:\Lua
copy /y src\lua53.dll C:\Lua
copy /y src\luac53.exe C:\Lua
mkdir C:\Lua\lua
现在将文件夹C:\Lua
添加到PATH
环境变量的开头(控制面板 - >系统 - >高级 - >环境变量)。
您现在可以使用lua53
命令运行Lua
文件夹C:\Lua\lua
适用于Lua模块。
luavs.bat
的内容:
@rem Script to build Lua 5.3 under "Visual Studio .NET Command Prompt".
@rem It creates lua53.dll, lua53.lib, lua53.exe, and luac53.exe in src.
@rem (contributed by David Manura and Mike Pall)
@setlocal
@set VERS=53
@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
@set MYLINK=link /nologo
@set MYMT=mt /nologo
cd src
%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
%MYLINK% /DLL /out:lua%VERS%.dll l*.obj
%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c
%MYLINK% /out:lua%VERS%.exe lua.obj lua%VERS%.lib
%MYCOMPILE% l*.c
del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj loslib.obj ltablib.obj lstrlib.obj loadlib.obj
%MYLINK% /out:luac%VERS%.exe *.obj
del *.obj
cd ..