lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Mar 25, 2020 at 4:27 PM Nereus <codecomplete@free.fr> wrote:
Hello,

I'm still a bit in the dark with Lua and modules but getting there.

LuaRocks comes with Lua 5.1, which is too old for some modules like dkjson:

=======
C:\Temp\Lua>luarocks install dkjson
Installing https://luarocks.org/dkjson-2.5-2.src.rock
dkjson 2.5-2 depends on lua >= 5.1, < 5.4 (5.1-1 provided by VM)
The system cannot find the path specified.
No existing manifest. Attempting to rebuild...
The system cannot find the path specified.
dkjson 2.5-2 is now installed in C:\Program Files\LuaRocks\systree (license:
MIT/X11)
=======

Did you try starting the REPL and requiring the module? If LuaRocks said it was installed, then it might have worked. Windows cmd sometimes outputs error messages that third-party programs cannot easily suppress, and "system cannot find the path specified" sounds like one of those IIRC. If it says installed, then those might be artifacts of attempting to do it one way and then falling back to another way, in which case they may be harmless.

So, I attempted to use MingW to compile Lua 5.3.5:
=======
1. Launch Mingw shell: C:\MinGW\msys\1.0\msys.bat
2. cd /c/temp/lua/Lua.5.3.5.src
3. make PLAT=mingw
4. make install
Files copied in c:\MinGW\msys\1.0\local\
=======

And then, I tried to compile LuaRocks with Lua 5.3.5:
=======
1. Open a cmd window
2. install.bat /MW /LV 5.3 /LUA c:\MinGW\msys\1.0\local\
lua.exe - System Error: The program can't start because lua53.dll is missing
from your computer. Try reinstalling the program to fix this problem.
=======

What is the right way to compile Lua so that LuaRocks will compile OK?
 
Lua does not have out-of-the-box support for compiling on Windows. Instead of trying to compile Lua the hard way, try the WinLua distributions. This is Lua (and LuaRocks, IIRC) pre-compiled in a sensible way for Windows. Trying to do it on your own is like reinventing the wheel. :-)
 
Thank you.

PS: Am I correct in understanding that some Lua modules are plain Lua so can
be installed by simply downloading the .lua file, while others a written in
C, hence the need to install a C compiler and tell LuaRocks about it?

Correct. A pure Lua library needs no compiler and can be manually installed by simply downloading the package and dropping the correct folder or file in the correct place. However, this can be tricky, and you're better off installing with LuaRocks anyway because it will automatically (when set up correctly) drop files in the right place and provide you with an easy way to update libraries.

If a library uses C, on the other hand, you need a C compiler installed and (typically) on your PATH to compile it during installation. Many of these are designed to use LuaRocks built-in compilation routines, and manually compiling such libraries can be harder than compiling Lua itself, so getting LuaRocks working is essential for those libraries.

Some languages *coughPythoncough* solve this issue by offering an official, pre-built binary for Windows and standardizing an "official" compiler for Windows, allowing library authors to pre-build their libraries with that compiler and offer binary downloads on the package manager so that no compiler is needed for Windows users to install it (since unlike most other OSes, it's rare for the average Windows user to have a C compiler installed, much less know how to use it correctly).

Lua can't benefit from this because different people use different compilers, and a Lua built with one compiler and a library built with a different compiler can't always talk to each other correctly, so it's necessary to use the same compiler for libraries that you use for Windows itself. With no "standard" compiler endorsed by the Lua Team, everybody was left to fend for themselves for quite some time.

WinLua is an good attempt to solve this issue, but what we really need is for the Lua Team to offer an official way to compile/install on Windows, and once that becomes a standard maybe we can begin to see Windows binary rocks on LuaRocks become more common. Until then, WinLua is the way to go.