Skip to content

Instantly share code, notes, and snippets.

@moteus
Last active November 2, 2021 00:15
Show Gist options
  • Save moteus/6823437 to your computer and use it in GitHub Desktop.
Save moteus/6823437 to your computer and use it in GitHub Desktop.
Lua/Luarocks Install instruction on Windows
-- make and install lua --
1. Download install http://mingw-w64.sourceforge.net/download.php
2. Download and unpack Lua source (http://www.lua.org/ftp)
Tested on Lua 5.1.5 and 5.2.2
3. Make Lua
- run mingw builds terminal
- cd to lua src dir
- run mingw32-make mingw
!NOTE! for Lua 5.1.5 you need edit `src\Makefile`
replace
`$(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files`
with
`$(AR) $@ $(CORE_O) $(LIB_O)`
4. Make `c:\Lua\5.x` and `c:\Lua\5.x\include` dirs
5. Make LUA_DIR/LUA_DIR_5_2 env varuable (c:\Lua\5.x)
6. copy lua.exe,lua5x.dll to %LUA_DIR% (rename lua.exe to lua5x.exe)
7. copy ... to %LUA_DIR%\include
8. Add %LUA_DIR%/%LUA_DIR_5_2% to PATH env variable
9. Add .LUA/.L52 ext to PATHEXT env variable
10.
ftype LuaScript="%LUA_DIR%\lua51.exe" "%1" %*
ftype LuaScript52="%LUA_DIR_5_2%\lua52.exe" "%1" %*
assoc .lua=LuaScript
assoc .l52=LuaScript52
------------------------------------------------------------------------------
install luarocks
copy `lua5x.exe` to `lua5.x.exe`
-- for lua 5.1 --
1. get luarocks source (https://github.com/keplerproject/luarocks) (i test with master on 2013-09-04 `44a397f4e0b3e2d802104706b84a8ecc6473d4ed`) and unpack this to luarocks_src_dir
cd luarocks_src_dir
win32pack wininst
cd wininst
2. run `install /MW /P c:\lua\LuaRocks /INC %LUA_DIR%\include /LIB %LUA_DIR% /BIN %LUA_DIR% /LV 5.1`
3. Set env variables:
PATH : c:\lua\LuaRocks\2.1
LUA_PATH : c:\lua\LuaRocks\share\lua\5.1\?.lua;c:\lua\LuaRocks\share\lua\5.1\?\init.lua
LUA_CPATH: c:\lua\LuaRocks\lib\lua\5.1\?.dll
4. Edit `c:\lua\LuaRocks\2.1\luarocks.bat`
Add `SET PATH=C:\Program Files\mingw-builds\x64-4.8.1-win32-seh-rev5\mingw64\bin;%PATH%`
5. Edit `c:\lua\LuaRocks\config.lua`
remove line `MSVCRT = 'MSVCR80'`
add two elements to variables table (CC = "gcc", LD = "gcc")
to test try
luarocks install date
luarocks install lbase64
lua5.1 -ldate -lbase64
-- lua 5.2 --
1-6 almost same as for lua 5.1
install /MW /P c:\lua\LuaRocks52 /INC %LUA_DIR_5_2%\include /LIB %LUA_DIR_5_2% /BIN %LUA_DIR_5_2% /LV 5.2
variables:
PATH : c:\lua\LuaRocks52\2.1
LUA_PATH_5_2 : c:\lua\LuaRocks52\share\lua\5.2\?.lua;c:\lua\LuaRocks52\share\lua\5.2\?\init.lua
LUA_CPATH_5_2 : c:\lua\LuaRocks52\lib\lua\5.2\?.dll
7. Edit `c:\lua\LuaRocks52\2.1\luarocks.bat`
Replace `SET LUA_PATH=` to `SET LUA_PATH_5_2=`
8. Rename `c:\lua\LuaRocks52\2.1\luarocks.bat` to `c:\lua\LuaRocks52\2.1\luarocks52.bat`
to test try
luarocks52 install date
luarocks52 install lbase64
lua5.2 -ldate -lbase64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment