Datasheet
Building Lua with Microsoft Visual C++
First, make sure that the SDK’s bin directory has been included in your system’s search path. Under the
SDK’s
include directory, make a subdirectory named usr. Similarly, under the SDK’s lib directory,
make a subdirectory named
usr. Additionally, as covered in the environment section, you should set the
LIB environment variable to the SDK’s lib and lib\usr directories, and the INCLUDE environment
variable to the SDK’s include and
include\usr directories. Your SDK may include a batch file named
vcvars32.bat that can help with this. If you modify these environment variables, exit and restart the
shell to have your changes take effect.
Create a directory in which to build Lua. The following lines assume that this will be
c:\dev:
c:
cd \
mkdir dev
cd dev
Download lua-5.1.1.tar.gz and place it in this directory. Extract the contents. Here are the com-
mands you would use with 7-zip:
7z x lua-5.1.1.tar.gz
7z x lua-5.1.1.tar
This creates a subdirectory named lua-5.1.1. Delete lua-5.1.1.tar at this point, like this:
del lua-5.1.1.tar
Drop into the src subdirectory like this:
cd lua-5.1.1\src
Create a new text file and add the following lines:
cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL *.c
del *.o
ren lua.obj lua.o
ren luac.obj luac.o
ren print.obj print.o
link /DLL /IMPLIB:lua5.1.lib /OUT:lua5.1.dll *.obj
link /OUT:lua.exe lua.o lua5.1.lib
lib /out:lua5.1-static.lib *.obj
link /OUT:luac.exe luac.o print.o lua5.1-static.lib
Save the file as build.bat in the current directory (c:\dev\lua-5.1.1\src).
While you’re still in the
src subdirectory, run the newly created batch script from the shell:
build
13
Chapter 1: Getting Situated
04_069172 ch01.qxp 1/2/07 7:53 PM Page 13