Datasheet
the distribution: use the arrow keys to drill into and out of directories and the contents of text and
HTML files. Press Q to exit
less or lynx when you are ready to return to the shell itself. If you are a
Windows user, note that the files have Unix-style line endings that will not be properly handled by
Windows Notepad, so you should use a programmer’s editor or a web browser to read them.
With your web browser, you can explore the hyperlinked Lua manual in the
doc subdirectory. The src
subdirectory contains all of the source code for the Lua interpreter, compiler, and core libraries. The etc
subdirectory contains miscellaneous files such as the Lua icon and the source code for an especially
small interpreter with reduced functionality. The
test subdirectory contains a number of Lua scripts
that provide an excellent survey of Lua’s capabilities. Some of these scripts push at the far reaches of
Lua’s domain, so don’t be dismayed if some appear rather dense at first.
Compiling Lua on Linux and Other Unix-Like Systems
One of the first things you should do at your shell is to check whether you have a functioning C com-
piler. To do so, execute the following command:
cc -v
If version and configuration information is displayed, then it’s likely that you’ve got everything you
need to successfully build Lua. If you receive a message indicating that the command
cc could not be
found, try executing
gcc -v instead. If neither of these commands work, you need to find out if either
the C development tools have not been installed or some configuration setting is simply keeping them
from being available to you.
Where you build Lua depends on your purposes. If you intend for Lua to be used by other users on your
system, and you have the appropriate privileges, you’ll want to select a standard location for source
code such as
/usr/local/src. Otherwise, your home directory is a logical choice. In the shell, change
your default working directory with the following command:
cd /usr/local/src
Alternatively, simply use cd to go to your home directory.
Assuming you are connected to the Internet, acquire the source package as follows:
wget http://www.lua.org/ftp/lua-5.1.1.tar.gz
The program wget is a standard tool for retrieving Internet resources such as web pages and other files.
If your system doesn’t have it, you can try
curl or an interactive web browser. The file you download
will be in the form of a tarball that has the extension
.tar.gz. Extract the contents as follows:
tar xzvf lua-5.1.1.tar.gz
The tar utility will recreate the same directory structure that the Lua authors used to package the source
materials. Drop into the newly created directory by executing the following command:
cd lua-5.1.1
8
Chapter 1: Getting Situated
04_069172 ch01.qxp 1/2/07 7:53 PM Page 8