How Do I Build Lua For Windows Using MinGW and MSYS?
Asked Answered
P

1

8

I have a book called Beginning Lua Programming which is suppose to go over the raw basics but it is sort of leaving me stranded. Here is an effort to condense 3 pages:

QUOTE:

The following environment variables are recommended for Windows:
UTIL_DIR=c:\program files\utility
LUA_DIR=c:\program files\lua\5.1
LUA_CPATH=?.dll;%LUA_DIR%\?.dll
LUA_PATH=?.lua;%LUA_DIR%\?.lua
The UTIL_DIR variable identifies the utility directory you created in the preceding section. 

After this, there is a segment about setting the 'windows search path' for lua. Basically, it tells me to look up the output of 'doskey /?' and 'path' and figure it out myself. I have no idea what these do, how to use them, and what the difference between them is.

I'm at my wits end. A detailed explanation or a link to a detailed blog/article or youtube video is EXTREMELY appreciated!

Psychoactive answered 20/5, 2013 at 2:45 Comment(0)
S
20

There are a few ways to get Lua working on your machine. If you just want to a functional Lua environment in a hurry with minimal fuss then consider downloading one of the precompiled Lua binaries. The common ones being Lua for Windows and LuaBinaries.

Building Lua with Mingw isn't too difficult:

  • First get your desired Lua version here.
  • Extract the tar file containing Lua's source somewhere. For this example, I'll assume you extracted to c:\lua
  • If you have Msys already set up, you can run the make file from that environment. From the Msys shell, you can build lua with the follow commands:

    cd /c/lua
    make PLAT=mingw
    make install
    
  • You should find lua.exe and luac.exe somewhere in there after the build completes. Lua should be ready for use at this point.

The regular cmd.exe shell can work too with some changes to the commands:

    cd lua
    mingw32-make PLAT=mingw

The make install assumes a *nix environment and so doesn't work under a normal windows cmd shell. In this case you can just manually copy the compiled files from .\lua\src to where you want or you can just run it directly from there if desired.

Sidesaddle answered 20/5, 2013 at 4:5 Comment(2)
If the OP is a complete newbie this OS answer may be of some help too.Chromolithograph
Nowadays, lua-users wiki is really helpful. And if you want to use msvc, this faq entry referred to by this blog will help you. The functions of different source codes can be found here 'Building Lua on other systems'.Camise

© 2022 - 2024 — McMap. All rights reserved.