Build 32-bit Lua in Windows 64-bit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Build 32-bit Lua in Windows 64-bit

christian govella

Hi,

 

I had to do a small change in Lua’s src/Makefile for building a 32-bit version of Lua in Microsoft Windows with TDM-GCC 64bit.

 

src/Makefile

@@ -128,7 +128,7 @@

 

 mingw:

        $(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \

-       "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \

+       "AR=$(CC) $(MYCFLAGS) -shared -o" "RANLIB=strip --strip-unneeded" \

        "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe

        $(MAKE) "LUAC_T=luac.exe" luac.exe

 

 

 

For building Lua in Microsoft Windows I followed this guide http://lua-users.org/wiki/BuildingLuaInWindowsForNewbies. In a system configured for 64-bit I thought I could build a 32-bit version of Lua by providing the option -m32. So I added -m32 option to make variables MYCFLAGS and MYLDFLAGS in the file build.cmd (step 6 in the guide Building Lua In Windows For Newbies) doing the following:

 

build.cmd

@@ -17,7 +17,7 @@

 set path=%compiler_bin_dir%;%path%

 

 cd /D %lua_build_dir%

-mingw32-make PLAT=mingw

+mingw32-make PLAT=mingw MYCFLAGS=-m32 MYLDFLAGS=-m32

 

 echo.

 echo **** COMPILATION TERMINATED ****

 

 

When building Lua for mingw platform, it looks like the archiver is set be the c compiler. Somehow it must also get the -m32 options. So to build successfully, I also had to do the small change in src/Makefile.

 

I thought this might be interesting for someone else. Or maybe someone might be able to suggest an easier and better way to build a 32-bit version of Lua in Microsoft Windows configured for 64-bit. I used Lua version 5.4.0.

 

 

Many Thanks,

Christian Govella