Datasheet

Use your text editor to prepare the following batch file. Adjust the first line if necessary to specify
the directory in which you installed TCC. The second line begins with
SET TCCCMD and ends with
-lkernel32 make sure it is all on one line. (The ; symbol indicates that the code line is too long to
print on one line in the book; the code that follows is a continuation of the first line. In other words, ;
tells you to keep typing on the same line.)
SET TCCDIR=c:\program files\tcc-0.9.23
SET TCCCMD=”%TCCDIR%\tcc\tcc” -D_WIN32 -I”%TCCDIR%\include” ;
-I”%TCCDIR%\include\winapi” -L”%TCCDIR%\lib” -lkernel32
ren luac.c luac.c0
ren print.c print.c0
%TCCCMD% -o lua.exe *.c
ren lua.c lua.c0
ren luac.c0 luac.c
ren print.c0 print.c
%TCCCMD% -o luac.exe *.c
ren lua.c0 lua.c
SET TCCDIR=
SET TCCCMD=
SET TCCIMP=
Save this file as build.bat in the current directory. Build Lua by running this batch script:
.\build
Although TCC can generate dynamic link libraries, the code that is shown here builds statically linked
versions of
lua.exe and luac.exe. Copy these to your utility directory as follows:
xcopy lua.exe “%UTIL_DIR%\*.*” /y
xcopy luac.exe “%UTIL_DIR%\*.*” /y
Building Lua with MinGW
The MinGW package provides you with all the command-line tools you need to develop Windows
applications. An optional related package, MSYS, includes a Unix-like shell and, among other tools,
awk,
bzip2, find, grep, sed, tar, vi, and which. The instructions that follow cover only the use of MinGW,
but MSYS is definitely worth investigating if you want the power and flexibility of working in a Unix-
like development environment. The MinGW website has an excellent FAQ (Frequently Asked Questions)
page as well as a comprehensive wiki to help you use the MinGW and MSYS systems to their fullest.
The following instructions show you how to install the MinGW system. You need about 50MB of space
available on your disk. Obtain the following files (or more recent versions if they are available) from the
current section of download page of the MinGW site,
www.mingw.org:
binutils-2.15.91-20040904-1.tar.gz
w32api-3.6.tar.gz
mingw-utils-0.3.tar.gz
gcc-core-3.4.2-20040916-1.tar.gz
mingw-runtime-3.9.tar.gz
16
Chapter 1: Getting Situated
04_069172 ch01.qxp 1/2/07 7:53 PM Page 16