Using Windows based package managers
If you do not wish to build and compile Lua yourself, you can use Windows based package managers like Winget, Scoop or Chocolatey.
Keep in mind that Winget and Chocolatey install lua from the same source, so you will only get up to Lua 5.1, Scoop however can install the latest version of Lua.
- Winget:
winget install "Lua for Windows"
as described in YoungForest's answer.
- Chocolatey:
choco install lua
- Scoop:
scoop install lua
If you installed Lua with one of these package managers and want to use LuaRocks, you will need to install it and GCC with the same package manager.
If you did not install LuaRocks with a package manager
My stupid ass did that so let me tell you how to fix it, I will be using Scoop as my example.
Specifying your version of Lua and GCC to LuaRocks when Lua was installed with Scoop
- Find out where LuaRock's config.lua file is on your system: run
luarocks
you should find it right at the end of the output in the "Configuration files" section
- Modify the config-x.y.lua file with the correct paths to your installations of Lua and GCC, mine looks like this:
variables = {
LUA = "C:\\Users\\admin\\scoop\\apps\\lua\\current\\lua54.exe",
CC = "C:\\Users\\admin\\scoop\\apps\\gcc\\current\\bin\\gcc.exe",
CXX = "C:\\Users\\admin\\scoop\\apps\\gcc\\current\\bin\\g++.exe",
}
LuaRocks tries to invoke GCC with the wrong command
If the config file is set correctly it shouldn't happen, but it happened to me.
In this case you can create a symlink of gcc.exe with this command as its name. If you installed it without a package manager for example, instead of trying gcc
it will try x86_64-w64-mingw32-gcc
so get in the directory where gcc.exe is located and in PowerShell do:
New-Item -ItemType SymbolicLink -Path .\x86_64-w64-mingw32-gcc.exe -Target .\gcc.exe
You should be able to see what command LuaRocks is trying in the error message when you try to install a library with it.
moai.exe
with Visual Studio. Read "Developing on Windows" section – Counterfeit