Luarocks to target multiple Lua versions and architectures (32/64 b)

190 views
Skip to first unread message

LPr Pontex

unread,
Apr 16, 2025, 4:44:41 PM4/16/25
to lu...@googlegroups.com
Hello,

(namely under Windows:)

It seems that Luarocks allows simple targeting the required library
build with "--lua-version x.y" and with "--lua-dir (...)" options
(especially with no lua.exe is to be found on PATH).

But how do I affect the architecture of the target - be 32b or 64b (Windows)?

Best regards,

Lukas

Sainan

unread,
Apr 16, 2025, 6:00:59 PM4/16/25
to lu...@googlegroups.com
It's possible someone can help you here on lua-l but just be advised that this mailing list is for the Lua language itself, and you might have better luck getting an answer in their forum on Github: https://github.com/luarocks/luarocks/discussions

-- Sainan

mjmouse9999

unread,
Apr 16, 2025, 7:21:47 PM4/16/25
to lua-l
> But how do I affect the architecture of the target - be 32b or 64b (Windows)?

If you are on Windows, it will generally be affected by whether you open it in a x64 or x86 Native Tools command prompt (which you will have to do in order to use MSVC for compiling).

Thijs Schreijer

unread,
Apr 17, 2025, 8:23:41 AM4/17/25
to lu...@googlegroups.com
LuaRocks goes to great lengths to detect binary compatibility, see https://github.com/luarocks/luarocks/blob/main/src/luarocks/core/sysdetect.tl

have a look

Thijs

LPr Pontex

unread,
Apr 17, 2025, 9:03:24 AM4/17/25
to lu...@googlegroups.com
Hello Thijs,
I need to build extensions (= .dll = "rocks") *both for 32b and 64b
architecture*: the rocks are to be used by both 32b and 64b
executables (which both run on my 64b machine, but this doesn't
matter).
So - although the luarocks is able to detect the system it's running
on, I still need to get both versions of rocks; and I'm looking for a
way to force luarocks to produce 32b or 64b rocks from its "rock
manifest".
Best,
Lukas

čt 17. 4. 2025 v 14:23 odesílatel 'Thijs Schreijer' via lua-l
<lu...@googlegroups.com> napsal:
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/ebce1297-1d64-4e75-9855-c8a8891b3554%40app.fastmail.com.

Thijs Schreijer

unread,
Apr 17, 2025, 11:39:53 AM4/17/25
to lu...@googlegroups.com
On Thu, 17 Apr 2025, at 15:03, LPr Pontex wrote:
> Hello Thijs,
> I need to build extensions (= .dll = "rocks") *both for 32b and 64b
> architecture*: the rocks are to be used by both 32b and 64b
> executables (which both run on my 64b machine, but this doesn't
> matter).
> So - although the luarocks is able to detect the system it's running
> on, I still need to get both versions of rocks; and I'm looking for a
> way to force luarocks to produce 32b or 64b rocks from its "rock
> manifest".
> Best,
> Lukas

be careful when mixing and matching binaries. They need to match, both on architecture, but also on runtimes. This post touches on some of those issues [1].

I have typically ran luarocks commands from a preconfigured shell, either an MSVC one or a MinGW based one, etc. In those shells you can configure the target. From there run LuaRocks commands.

Not 100% sure, but it might just work.
Thijs


[1]: https://github.com/luarocks/luarocks/issues/1760#issuecomment-2706950674

LPr Pontex

unread,
Apr 20, 2025, 4:38:53 PM4/20/25
to lu...@googlegroups.com
Hello Thijs,

the LuaWinMulti seems nice - I downloaded MinGW and put it in PATH,
and LuaWinMulti built all Lua versions ("dialects") successfully.
But - how do I affect these - c:\Lua\bin\lua51.exe,
c:\Lua\bin\lua52.exe, ..., c:\Lua\bin\luarocks51.bat,
c:\Lua\bin\luarocks52.bat, ... - be built or will produce rocks either
for 32b or 64b architecture?
Or does it depend on MinGW version (32/64)? But MinGW 32b might
produce both 32b and 64b applications, and MinGW 64b might produce
both 32b and 64b applications, too... So how to pass the information
about which architecture to target?

Best regards,

Lukas


čt 17. 4. 2025 v 17:39 odesílatel 'Thijs Schreijer' via lua-l
<lu...@googlegroups.com> napsal:
>
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/0c584db1-77a8-4a1b-b149-3766d7892dd4%40app.fastmail.com.

Thijs Schreijer

unread,
Apr 21, 2025, 9:09:56 AM4/21/25
to lu...@googlegroups.com

On Sun, 20 Apr 2025, at 22:38, LPr Pontex wrote:
> Hello Thijs,
>
> the LuaWinMulti seems nice - I downloaded MinGW and put it in PATH,
> and LuaWinMulti built all Lua versions ("dialects") successfully.
> But - how do I affect these - c:\Lua\bin\lua51.exe,
> c:\Lua\bin\lua52.exe, ..., c:\Lua\bin\luarocks51.bat,
> c:\Lua\bin\luarocks52.bat, ... - be built or will produce rocks either
> for 32b or 64b architecture?
> Or does it depend on MinGW version (32/64)? But MinGW 32b might
> produce both 32b and 64b applications, and MinGW 64b might produce
> both 32b and 64b applications, too... So how to pass the information
> about which architecture to target?
>
> Best regards,
>
> Lukas
>

For the MSVC it depends on how you set up your shell. For the gcc based ones it probably depends on the distro you are using.

Thijs

Thijs Schreijer

unread,
Apr 21, 2025, 12:42:14 PM4/21/25
to lu...@googlegroups.com
I did some digging in my Windows setup, here's a snippet from a batch file used to generate some configurations:

@echo off
REM ============ CUSTOMIZATION SECTION ============


@REM SET Environment_Name=msvc32
@REM SET Compiler_Setup_Cmd="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=x86

@REM SET Environment_Name=msvc64
@REM SET Compiler_Setup_Cmd="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64

SET Environment_Name=tdm32
SET Compiler_Setup_Cmd="C:\TDM-GCC-32\mingwvars.bat"

@REM SET Environment_Name=tdm64
@REM SET Compiler_Setup_Cmd="C:\TDM-GCC-64\mingwvars.bat"

LPr Pontex

unread,
Apr 22, 2025, 10:28:54 AM4/22/25
to lu...@googlegroups.com
Hello Thijs,

could you provide the content of your "C:\TDM-GCC-32\mingwvars.bat"
and "C:\TDM-GCC-64\mingwvars.bat"?
I'd like to compare with those in MinGW install dirs on my computer .

Lukas

po 21. 4. 2025 v 18:42 odesílatel 'Thijs Schreijer' via lua-l
<lu...@googlegroups.com> napsal:
>
>
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/6808999b-51d4-49bb-9754-d4dd514de6f1%40app.fastmail.com.

Thijs Schreijer

unread,
Apr 22, 2025, 11:26:56 AM4/22/25
to lu...@googlegroups.com

On Tue, 22 Apr 2025, at 16:28, LPr Pontex wrote:
> Hello Thijs,
>
> could you provide the content of your "C:\TDM-GCC-32\mingwvars.bat"
> and "C:\TDM-GCC-64\mingwvars.bat"?
> I'd like to compare with those in MinGW install dirs on my computer .
>
> Lukas

It's from a very old TDM release. Contents:

@echo.
@echo Setting up environment for using MinGW with GCC from %~dp0.
@set PATH=%~dp0bin;%PATH%

and the 64bit one is identical. So seems they only setup the path such that the compiler suite is first in the path.

hth
Thijs

LPr Pontex

unread,
Apr 29, 2025, 4:50:25 PM4/29/25
to lu...@googlegroups.com
Hello Thijs,

I finally built both the 32b and 64b versions of various Lua versions
("dialects").
Although I tried MinGW, too, I decided finally for VS as the MinGW
compiled binaries complained about a missing mingw DLL (I didn't
investigate this any deeper.).

If you are interested more closely how I did it, I attach here a
simple manual (ReadMe.LPr.md) and both batches (.bat) I used for
compilation. (The ".ba~" files must be renamed to ".bat" as the ".bat"
files are not allowed here as attachments.)
Feel free to add whatever from that into your LuaWinMulti project
(documentation) if you decide so.

The project and your hints helped me a lot.

Best regards,

Lukas

út 22. 4. 2025 v 17:26 odesílatel 'Thijs Schreijer' via lua-l
<lu...@googlegroups.com> napsal:
>
>
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/720753c3-a5e1-481d-bcfd-31bb828aa10c%40app.fastmail.com.
ReadMe.LPr.md
Make.LPr.VC.32b.ba~
Make.LPr.VC.64b.ba~
Reply all
Reply to author
Forward
0 new messages