Skip to content

Instantly share code, notes, and snippets.

@Egor-Skriptunoff
Last active July 26, 2022 22:11
Show Gist options
  • Save Egor-Skriptunoff/30c9a12665d77e33e35499ff2664fcd5 to your computer and use it in GitHub Desktop.
Save Egor-Skriptunoff/30c9a12665d77e33e35499ff2664fcd5 to your computer and use it in GitHub Desktop.
How to build LuaJIT for Windows

How to build 64-bit LuaJIT 2.1 binaries for Windows

  1. Download the latest LuaJIT sources

    • Create temporary folder for LuaJIT sources.
      I assume you would use C:\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 folder C:\Temp\luajit\

    • You can uninstall "Git for Windows" application now.
      It's portable, so just remove its folder.

  2. Build LuaJIT binaries using MinGW64

    • Download and install MSYS2.
      It is recommended to install MSYS2 in the default destination folder C:\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 asked Proceed with installation? [Y/n], answer Y and press Enter.

    • 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

    • Close the MSYS2 console window.

    • You can uninstall MSYS2 application now at Control Panel -> Programs and Features.

  3. Take LuaJIT binaries

    • Open folder C:\Temp\luajit\src\
      Sort files by "Date Modified".

    • Find 2 files: luajit.exe and lua51.dll among the most recently modified.

    • Take these 2 files and put them to the folder where Lua binaries should be on your system.

    • You can remove LuaJIT sources now.
      Delete folder C:\Temp\luajit\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment