Windowless LuaJIT does not create a console window.
It runs invisible for user.
Please note that "windowless" means "doesn't have stdin, stdout and stderr".
You will not be able to see error message.
io.read()
, io.write()
and print()
in your Lua script will not work.
But in some situations invisible LuaJIT is just what you need very much.
For example, to avoid a GUI application (especially a game) to lose input focus when some background Lua script is started.
-
Download the latest LuaJIT sources
-
Create temporary folder for LuaJIT sources.
I assume you would useC:\Temp\
folder. -
Download and install Portable "Git for Windows"
-
Run
git-cmd.exe
, a console window will open. -
Execute the following commands in this console window:
cd /d C:\Temp\
git clone https://luajit.org/git/luajit.git
cd luajit
git checkout v2.1
-
Close the console window.
Now you have LuaJIT 2.1 sources in the folderC:\Temp\luajit\
-
You can uninstall "Git for Windows" application now.
It's portable, so just remove its folder.
-
-
Modify LuaJIT sources
-
Open folder
C:\Temp\luajit\src\
-
Find the file
luajit.c
, right-click it and select "Edit".
Notepad will open. -
Scroll down to the end of the file and add the following 2 lines after the last line:
int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* pCmdLine, int nShowCmd)
{ return main(__argc, __argv); }
-
Save the file and close Notepad.
-
-
Build LuaJIT binaries using MinGW64
-
Download and install MSYS2.
It is recommended to install MSYS2 in the default destination folderC:\msys64\
,
but you may choose another path consisting of English letters without spaces. -
After installation is complete, a MSYS2 console window will open.
Execute the following command in this MSYS2 console window:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make
When askedProceed with installation? [Y/n]
, answerY
and pressEnter
. -
Close this MSYS2 console window and open a new one by clicking the
MSYS2 MinGW 64-bit
menu item in Windows Start menu.
Execute the following commands in the new MSYS2 window:
cd /c/Temp/luajit/
mingw32-make CFLAGS=-DLUAJIT_ENABLE_LUA52COMPAT TARGET_LDFLAGS=-mwindows
-
Close the MSYS2 console window.
-
You can uninstall MSYS2 application now at
Control Panel
->Programs and Features
.
-
-
Take LuaJIT binaries
-
Open folder
C:\Temp\luajit\src\
Sort files by "Date Modified". -
Find
luajit.exe
among the most recently modified.
Rename it towluajit.exe
-
Take 2 files:
wluajit.exe
andlua51.dll
and put them to the folder where Lua binaries should be on your system. -
You can remove LuaJIT sources now.
Delete folderC:\Temp\luajit\
-