Skip to content

Instantly share code, notes, and snippets.

@cequella
Created June 8, 2019 16:19
Show Gist options
  • Save cequella/39f365d2dd07d0398bdc892358c65351 to your computer and use it in GitHub Desktop.
Save cequella/39f365d2dd07d0398bdc892358c65351 to your computer and use it in GitHub Desktop.
Compiling Lua in Visual Studio
Preparation
1 - Download lua source in https://www.lua.org/download.html
2 - Unpack (use 7-zip)
3 - Create an C:\src\lua
4 - In C:\src\lua create dirs: include, lib, bin and doc
5 - Copy 'doc' from lua.tar.gz to C:\src\lua\doc
6 - Copy all files from lua.tar.gz src, to C:\src\lua\include
Creating a .lib and .dll
1 - Create a new blank project in Visual Studio
2 - Set to 'Release' and 'x64'
3 - Right click 'Solution manager' > 'Resource files' > '... existing files'
4 - Add all files from C:\src\lua\include
5 - Right click 'Solution' > 'Properties'
6 - Set 'General' > 'Setting type' to '...DLL' and 'Apply'
7 - 'C/C++' > 'General' > 'Preprocessor' > 'Definitions of preprocessing' add 'LUA_BUILD_AS_DLL;' before current value and 'Apply'
8 - Remove 'lua.c' and 'luac.c' files
9 - Build
Obs: It will generate 'lua.lib' and 'lua.dll' files. Copy them to C:\src\lua\lib
Creating lua
1 - Add 'lua.c' from C:\src\include file
2 - Right click 'Solution' > 'Properties'
3 - Set 'General' > 'Setting type' to '... exe' and 'Apply'
4 - C/C++' > 'General' > 'Preprocessor' > 'Definitions of preprocessing' remove 'LUA_BUILD_AS_DLL;' before current value and 'Apply'
5 - Build
Obs: It will generate a 'lua.exe', copy it to C:\src\lua\bin
Creating luac
1 - Remove 'lua.c' file again
2 - Add 'luac.c' from C:\src\include file
3 - Build
Obs: It will generate a 'lua.exe'. Rename it to 'luac.exe' and copy it to C:\src\lua\bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment