在Windows环境下构建Lua
一:准备软件
1.C-compiler(TDM GCC) http://tdm-gcc.tdragon.net/download
2.Lua源代码 http://www.lua.org/download.html
3.用2345好解软件更方便。解压软件7-zip,这里不使用官方版本
http://portableapps.com/apps/utilities/7-zip_portable
二:安装软件
- gcc
安装完成gcc后的目录结构如下
2.安装解压软件 7-Zip (用好压吧,反正这一步就是把lua的目录解压出来)
3.创建一个cmd文件,如build.cmd,并将以下文本拷贝进去
@echo off
:: ========================
:: file build.cmd
:: ========================
setlocal
:: you may change the following variable‘s value
:: to suit the downloaded version
set lua_version=5.2.2
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
4.双击运行build.cmd,等待完成
此时安装目录下的文件结构: