lua-users home
lua-l archive

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

On Wed, Mar 25, 2020 at 5:54 PM Nereus <> wrote:
Thanks for the help.

No problem. I'm one that has tried to navigate the world of compiling Lua and LuaRocks in Windows on my own in the past using Visual Studio. It's painful to say the least.

Jonathan Goble wrote
> 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. :-)

The Lua site doesn't seem to mention  WinLua <>  .
I'll take a look.

WinLua is a third-party project with no official connection to the main Lua project, hence why it doesn't appear.
As for compiling Lua, installing LuaRocks, and downloading+loading a Lua
module, this worked:
1. Start a Mingw shell: C:\MinGW\msys\1.0\msys.bat
2. Cd to where the Lua source code lives, eg. cd /c/temp/lua/Lua.5.3.5.src
3. make mingw
4. make install INSTALL_TOP=c:/lua/5.3 TO_BIN="lua.exe luac.exe lua53.dll"
5. Close the Mingw shell, and open a DOS (cmd.exe) box
6. Cd where the LuaRocks source code lives, eg. cd
7. install.bat /F /MW /LV 5.3 /LUA c:\lua\5.3
8. Edit Windows' SYSTEM and USER env't variables as shown by LuaRocks
9. To check that LuaRocks works, in a DOS box, run eg. "luarocks install
10. Finally, launch Lua and load the module with "local json = require

Note: It looks like Lua ignores the SYSTEM %LUA_PATH%, and only read the
USER %LUA_PATH%, leading to this:
stdin:1: module 'dkjson' not found:
        no field package.preload['dkjson']
        no file
        no file
        no file
        no file 'c:\lua\5.3\\lib\lua\5.3\dkjson.dll'

So edit the USER %LUA_PATH% to include

Regardless of this issue, I'm surprised the LuaRocks installer doesn't take
care of updating Windows' user env't itself.

luarocks (the command) has a "path" subcommand that outputs commands to update the environment with these paths. I don't recall exactly how that command works anymore, but you could look into that.

But yes, I wish LuaRocks updated the PATH itself. (And again, I believe WinLua might take care of this for you.)
Too bad Lua needs LuaRocks and a C compiler: At first sight, it looked lean
and mean compared to Python… until I learned that bare Lua can't do much out
of the box :-/

Lua is designed chiefly for embedding onto virtually anything, so it is extremely small by design, and limited to ANSI C exclusively, which rules out things like sockets and internet access. For those embedding applications, it definitely is lean and mean. Using it as a stand-alone scripting language is something the community began doing on their own, and tools like LuaRocks sprung up around that to support that. Even LuaRocks isn't an officially endorsed tool by the Lua Team. But if you want to use Lua for serious applications, you have to be willing to get your hands dirty. Lua's chief advantage over Python for general-purpose programming is that it's faster, but for a lot of stuff, that isn't important.