Datasheet
There are two excellent open-source packages for Windows that blur the Windows-Unix distinction
somewhat. One of them, the Cygwin system, provides many GNU and Linux tools (including various
shells and development tools) for Windows platforms. It is available at
www.cygwin.com. Applications
that you build with this environment will run only on systems that have Cygwin installed. If you want
to install Lua in this environment, follow the directions for building Lua on Unix-type systems.
The other package is the MinGW system, which enables you to use standard Unix-like tools to build
applications that run on all 32-bit desktop versions of Windows without any extra support libraries. This
first-rate system is available at
www.mingw.org.
As you read this chapter, section headers will indicate whether a Unix-like system or Windows is being
discussed. You can skip the sections that don’t apply to your platform.
The Lua interpreter, typically named
lua.exe in Windows and lua in Unix and friends, is a small com-
mand-line program that executes your scripts either interactively or noninteractively. You’ll become
familiar with the Lua interpreter and both of these modes in the first chapters of this book.
A note about these names: In this book, Lua refers to the Lua programming language or implementation,
and
lua refers to the Lua interpreter.
To install Lua, you can download a package that has been compiled for your particular operating system
platform, or download the source code and compile it yourself. There are the advantages and disadvan-
tages to each approach, as the following sections discuss.
Building Lua Yourself
Compiling Lua is straightforward. Lua, including the language processor and its core libraries, is written
in plain vanilla C so that it can be built on a wide variety of platforms with any ANSI-compliant C com-
piler. The advantage is that the resulting libraries and interpreter program are compatible with the sys-
tem on which it’s built. This is one of the principal advantages of open-source software in general. As
long as the target platform supports the tools and libraries needed to compile the source code — in Lua’s
case, this is a standard C compiler—the resulting binary program is compatible with the platform.
2
Chapter 1: Getting Situated
Lua Versions
In the instructions that follow, you’ll see references to version 5.1.1. A later version of
Lua may be available as you read this. As Lua evolves, some improvements are made
that require changes to existing scripts. Your decision is either to install a version of
Lua later than 5.1.1 and encounter possible instances where you have to modify the
scripts and libraries in this book, or to install version 5.1.1 and forgo any improve-
ments that may have been made to Lua. The Lua manual includes a section at the end
named “Incompatibilities with Previous Versions” that can help you decide. If you
install a later version, you’ll need to make corresponding changes to the commands
and directory names used in this chapter.
04_069172 ch01.qxp 1/2/07 7:53 PM Page 2