How to compile Lua 5.3.0 for Windows

Friday, January 16th, 2015 | Dennis D. Spreen | Lua

This is a tutorial on how to compile Lua 5.3.0 for Windows (executable and DLL) with Microsoft Visual Studio Express.

This tutorial on how to compile Lua for Windows is based on the great video How to Manually Install Lua 5.2 on Windows – thank you!

1. download and install Visual Studio 2010 Express (Windows 7) or Visual Studio 2012 Express (Windows 8) – do not use any older/newer version (haven’t tested them)

2. download and extract the Lua 5.3.0 source code

3. open a Visual Studio Command prompt, navigate to the extracted Lua src\ folder and run inside this folder the following commands

You’re done! You should now have a lua.exe interpreter, a luac.exe compiler and a lua5.3.0.dll.

Tags:

21 Comments to How to compile Lua 5.3.0 for Windows

Kochise
February 3, 2015

What about sharing the compiled binaries to avoid downloading a 600 MB compiler suite from Microsoft ?

Dennis D. Spreen
February 3, 2015

here you go lua5.3.0.zip
If you’d compile it by yourself, you would be able to adjust some settings (luaconf.h) by your needs.

Sweet
February 4, 2015

x86 and x64 Microsoft Visual Studio 2012 Express Compile
http://1drv.ms/1DEAkLw

and Thanks for compile tip Dennis.

Roland Chastain
February 5, 2015

Thank you sir! I am very glad to have found your tutorial.

[…] 參考自 How to compile Lua 5.3.0 for Windows P.S. 這篇文章是參考自 Youtube […]

Carl
January 5, 2016

Awesome! I was looking for something like this!

muminoi
March 21, 2016

Thank you, safe me many hours

VG
April 24, 2016

The build script you posted didn’t work properly for me. There were build errors and it didn’t output a DLL. I modified it so it works, and compiles much faster:

del *.obj *.dll *.lib *.o *.exp

cl -MP -MD -O2 -c -DLUA_BUILD_AS_DLL *.c
ren luac.obj luac.o
link -subsystem:console -dll -implib:lua53.lib -out:lua53.dll *.obj
link -out:lua.exe lua.obj lua53.lib
lib -out:lua53-static.lib *.obj
link -out:luac.exe luac.o lua53-static.lib

lamonese
April 27, 2016

Can someone tell me how I compile the interpreter and the dll for x64?

[…] Anleitung: von Dennis D. Spreen, diese bezieht sich auf Visual Studio 2010/2012 aber es sollte auch mit der aktuellen VS Version […]

busyBeaver
July 4, 2016

Hi lamonese,
I build 64-bit Lua with VS2014/15 (win10). You find the hints (written in german) here:

* how to prepare VS : https://lua64bit.wordpress.com/2016/07/03/wie-erstelle-ich-mit-vs-ein-64-bit-modul/
* build 64-bit lua: https://lua64bit.wordpress.com/2016/07/03/selfmade-lua/

Hosting Deutschland
July 18, 2016

To keep with Lua’s dynamic nature Ravi uses a mix of compile type checking and runtime type checks. However due to the dynamic nature of Lua, compilation happens at runtime anyway so effectually all checks are at runtime.

concerned joe
August 16, 2016

ummm VG… i’m concerned about the del command, so im not using your command until i get that error

Arjan Wooning
January 19, 2017

Hi Dennis,
Thanks for your lua5.3.0.zip compiled package from 2015. Still works like a charm :-).
I’m using it with the Atom editor and linter-lua package. Perfect!
Arjan

Alisson
February 3, 2017

how do i compile wlua for lua 5.3.4 or 5.3.3?

tp
November 1, 2017

Thank you so much for your help, I just compiled lua with msvc2015 32 bits thanks to you

Vlad
June 10, 2019

Hello,

I came here by hazard, if someone is interested, this is the Makefile I use to statically link Lua with MSVC (embedded usage).

https://github.com/vtudorache/lua-msvc/blob/master/Makefile

[…] posts How to compile Lua 5.3.0 for Windows How to compile Lua 5.3.0 as a Mac OS X dynamic library How to compile Lua 5.3.0 for Android as a […]

Dennis D. Spreen
June 25, 2019

@Vlad: Thank you!

[…] cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c ren lua.obj lua.o ren luac.obj luac.o link /DLL /IMPLIB:lua5.3.0.lib /OUT:lua5.3.0.dll *.obj link /OUT:lua.exe lua.o lua5.3.0.lib lib /OUT:lua5.3.0-static.lib *.obj link /OUT:luac.exe luac.o lua5.3.0-static.lib – from https://blog.spreendigital.de/2015/01/16/how-to-compile-lua-5-3-0-for-windows/ […]

Leave a comment

About Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.

Search

QR Code

Categories