I want to share a idea about lua.exe on Windows.
currently lua.exe is linked with lua52.dll, I have made some try to static link lua source to lua.exe, and export all symbols from lua.exe. I used a lua52.def to make a forwarder dll for compatible. In this way, lua on Windows is just the same as lua on Linux.
I use MinGW and one.c from Luiz, to compile a single-alone lua.exe, just like this:
:build_mgw
@set srcdir=..\src\
@set CFLAGS=-s -O3 -Wall
@echo build lua.exe ...
windres -i res\lua.rc -o lua_res.o
gcc %CFLAGS% -o lua.exe -DLUA_BUILD_AS_DLL -DMAKE_LUA one.c lua_res.o -Wl,--out-implib,liblua.exe.a
@echo build luac.exe ...
windres -i res\luac.rc -o luac_res.o
gcc %CFLAGS% -o luac.exe -DMAKE_LUAC one.c luac_res.o
@echo build lua52.dll ...
gcc -s -mdll -o lua52.dll -Wl,--out-implib,liblua52.dll.a lua52.def -L. -llua.exe
@echo build liblua52.a ...
@del *.o 2>nul
gcc %CFLAGS% -c %srcdir%*.c
@del lua.o luac.o
ar rcs liblua52.a *.o
@del *.o 2>nul
```
notice that I used a lua.rc (for icon of exe) from luadist project.
I have tried compile IUP, CD (from tecgraf) to this lua.exe, it seems worked! I made some changes to iup and cd, first, I modified code to export luaopen_iup instead of luaopen_iuplua (all symbols are added, original symbols are keeped). and build then using MinGW static library:
set TEC_UNAME=mingw4
set MINGW4=gcc
make
after that, I manually link .a file into .dll file, and makes iup.dll both export iup's symbol and Lua's symbol. and iup.dll is linked againest lua.exe:
```
@setlocal
@set libdir=-Lim\lib\mingw4 -Lcd\lib\mingw4 -Liup\lib\mingw4
@set libs=-L. -llua.exe -lcomctl32 -lcomdlg32 -lole32 -luuid -lgdi32 -lwinspool
gcc -mdll -mwindows -s -o iup.dll ^
iup\src\iup.def iup\srclua5\iuplua.def ^
-O2 -DIUP_DLL -I iup\include iup\src\win\iupwindows_main.c ^
%libdir% -liup -liuplua52 %libs%
gcc -mdll -mwindows -s -o cd.dll ^
cd\src\cd.def cd\src\lua5\cdlua5.def ^
%libdir% -lcd -lcdlua52 -lfreetype6 -lz %libs%
gcc -mdll -mwindows -s -o iupcd.dll ^
iup\srccd\iupcd.def iup\srclua5\iupluacd.def ^
%libdir% -liupcd -liupluacd52 -lz %libs% iup.dll cd.dll
gcc -mdll -mwindows -s -o iupcontrols.dll ^
iup\srccontrols\iupcontrols.def iup\srclua5\iupluacontrols.def ^
%libdir% -liupcontrols -liupluacontrols52 %libs% iupcd.dll iup.dll cd.dll
```
this is the downloadable result:
I have this idea from node.js, all node C modules are linked against node.exe, and no node.dll exists.
what about just dist lua in this format? do not offer lua52.dll, but just lua.exe (and can add icon and manifest to use XP style, just like the one above), and all C module are linked against .exe but not .dll, for compatible case we can offer a lua52.dll for bridge.
any comments welcome :)
--
regards,
Xavier Wang.