[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Help needed Building static binaries on Windows
- From: Stefan Schroeder <ondekoza@...>
- Date: Thu, 28 Nov 2019 11:44:04 +0100
I can now confirm that srlua-102 compiles and runs as designed on
Windows using this additional Makefile and with no change to the
sources.
The file below successfully runs with mingw32-make on the cmd-shell
and also with plain 'make -f Makefile.mingw' in the Cygwin-terminal.
I can now create my binaries for Windows as desired. Tested with the
versions that I noted down on the Wiki-page:
https://lua-users.org/wiki/BuildingLuaInWindowsForNewbies at the
bottom.
Next steps could be:
(1) Adding a Windows-resources file (for the icon and some metadata
with windres);
(2) compile statically to avoid the need to copy all the DLLs.
(3) Generating an NSIS-installer configuration to pack my app in an installer.
(->1) has been done by some srlua-forks on Github.
(->2) I am going to investigate with low priority
(->3) Should be pretty straightforward. Have done it before. (if 3 is
done, 2 becomes less important).
I say, it's really great what you can do with Lua. It's so incredibly versatile.
## Makefile.mingw
# Makefile for srlua for mingw32, to be run in Windows-cmd shell.
# Contributed to srlua by Stefan Schroeder under the same license
# conditions that srlua is published under.
#
# Change this setting to meet your configuration:
LUA_TOPDIR= d:/Lua/5.1
# Depending on your Lua-distro, the dll might also be located
# elsewhere:
LUA_DLL=$(LUA_TOPDIR)/lib/lua5.1.dll
# Everything below this line should be ok.
LUA_INCDIR= $(LUA_TOPDIR)/include
LUA_LIBDIR= $(LUA_TOPDIR)/lib
CC=mingw32-gcc -std=c99 -Wall -O2
CXX=mingw32-g++.exe
all: check bin test
check:
ifneq ("$(wildcard $(LUA_DLL))","")
@echo "Lua-DLL was found. You are good to go."
else
$(error Lua-DLL was NOT found. Cannot continue. Please fix LUA_DLL")
endif
bin:
$(CC) -static-libgcc -c srglue.c -o glue.o
$(CXX) -o glue.exe glue.o -s
$(CC) -static-libgcc -I. -I$(LUA_INCDIR) -c srlua.c -o srlua.o
$(CXX) -o srlua.exe srlua.o -s $(LUA_DLL)
# The 'test' target patches the PATH temporarily, so that the DLL
# is in the PATH.
test:
./glue.exe ./srlua.exe test.lua out.exe
cmd /c "SET PATH=%PATH%;$(LUA_LIBDIR)&out.exe 123 abc"
.PHONY: all bin test