Skip to content

Developer's Build Guide

Cody Tilkins edited this page Feb 28, 2021 · 4 revisions

LuaConsole has a few inputs into GCC or other environments. Simply put, you can build the driver in one command and a package in two - one being luajit the other being the actual package. For vanilla lua targets, a bit more is going on, but not much.

Building the driver in one command

REM mingw64
gcc -Wall -O2 -Lsrc -Llib -Ldll -Iinclude -Isrc "-DDEFAULT_LUA=libluajit.dll" -o luaw.exe src/luadriver.c

# linux
gcc -Wall -O2 -Lsrc -Llib -Ldll -Iinclude -Isrc "-DDEFAULT_LUA=libluajit.dll" -o luaw src/luadriver.c -ldl

Building a package in one command

REM mingw64
gcc -Wall -O2 -g0 -shared -Lsrc -Llib -Ldll -Iinclude -Isrc -DLC_LD_DLL -DLUA_JIT_51 -o liblcluajit.dll src/ldata.c src/jitsupport.c -lluajit

#linux
gcc -Wall -O2 -g0 -fPIC -shared -Wl,-E -Lsrc -Llib -Ldll -Iinclude -Isrc -DLC_LD_DLL -DLUA_JIT_51 -o liblcluajit.so src/ldata.c src/jitsupport.c -lluajit

Note: In packages, .dll and .so are named with the prefix lib. So renaming must happen with luajit.

Building luajit in one command

REM mingw64
make "-j%NUMBER_OF_PROCESSORS%"

# linux
make "-j$(nproc)"

Building lua in four commands

REM mingw64
gcc -std=gnu99 -Wall -O2 -g0 -c *.c
del lua.o
objcopy --redefine-sym "main=luac_main" luac.o
gcc -std=gnu99 -Wall -O2 -g0 -shared -Wl,--require-defined,luac_main -o liblua-5.4.2.dll *.o

# Linux
gcc -std=gnu99 -Wall -O2 -g0 -c *.c
rm lua.o
objcopy --redefine-sym "main=luac_main" luac.o
gcc -std=gnu99 -Wall -O2 -g0 -fPIC -shared -Wl,-E -Wl,--require-defined,luac_main -o liblua-5.4.2.so *.o -lm -ldl