D
Deleted member 2
Guest
I'm new to the Lua programming language. How to install Lua on Windows?
I've searched for videos but no luck.
I've searched for videos but no luck.
$ pacman -S ${MINGW_PACKAGE_PREFIX}-lua
$ lua
Is there any program with highlighting and error checking where I can just click build like Netbeans?There are several ways to do it. I personally favour using the MSYS2 installer because it also allows me
to build a lot of useful other packages. The method goes as follows:
1) Download and install MSYS2 following the instructions at the link above. Then, assuming MSYS2 is installed
at the default location C:\msys32 (if not, change the paths below accordingly):
2) Open a MinGW shell using the launcher C:\msys32\mingw64.exe (or C:\msys32\mingw32.exe if you
have a 32-bit system), and install Lua using the following command (here the $ sign is the shell prompt):
Bash:$ pacman -S ${MINGW_PACKAGE_PREFIX}-lua
Now you can use the Lua interpreter from any MinGW shell, by just typing the lua command in it:
Bash:$ lua
If you want to use it also from the Windows command prompt, you have to append the path C:\msys32\mingw64\bin
to the Windows PATH environment variable (or C:\msys32\mingw32\bin, on a 32-bit system).
(If you don't know what PATH is ,or how to modify it, just google "windows PATH environment variable" and you'll
find plenty of instructions).
Is there any program with highlighting and error checking where I can just click build like Netbeans?
print "Hello, Lua!"
hello_lua.lua
(remember the .lua file extension.)C:\TDM-GCC-64\
directorylua-5.4.1.tar.gz
on Windows. The .tar.gz
file format is very common on Linux, but not on Windows.lua-5.4.1.tar.gz
to your C:/
directorylua-5.4.1.tar.gz
and click on "open with".tar.gz
C:\Program Files\7-Zip
and select 7zFM
(7-Zip File Manager)C:/
directoryC:/gcc-lua-install/
lua-5.4.1
to C:/gcc-lua-install/
TDM-GCC-64
to C:/gcc-lua-install/
build.cmd
inside C:/gcc-lua-install/
set lua_version=5.4.1
in the script below.@echo off
:: ========================
:: file build.cmd
:: ========================
setlocal
:: you may change the following variable's value
:: to suit the downloaded version
set lua_version=5.4.1
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-64\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
build.cmd
hello.lua
print "I built Lua on Windows from sources!"
to hello.lua
C:\gcc-lua-install\lua\bin
lua the-path-to-your-script\hello.lua
C:\gcc-lua-install\lua\bin
directory. Therefore, we add the Lua executable to the Windows 10 Environment Variables.lua
and hit enterLua 5.4.1 Copyright (C) 1994-2020 Lua.org, PUC-Rio