Building Lua, dynamic linking using OW IDE

From Open Watcom

Revision as of 00:34, 6 September 2008; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

Obtain the current source distribution and unpack into an empty subdirectory.

First we build lualib.dll

Fire up the OW IDE.

Create a new target named lualib and of type dll

The file list is given in the file INSTALL but here is it anyway, insert these files into the target.

 lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
 lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c
 ltable.c ltm.c lundump.c lvm.c lzio.c
 lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c
 ltablib.c lstrlib.c loadlib.c linit.c

In / menu / options / C compile switches

Macro definitions

 LUA_BUILD_AS_DLL WIN32

I'd set space optimisation and no debug. (the code is fine)

Save the project.

Hit compile. All being well a .dll appears.

Now we build the interpreter

Add a new target into the same project, name it lua and of type command line executable.

Populate the source files pane with just one file,

 lua.c

Macro

 WIN32

/menu/options/windows linking switches

Stack op, something much larger than OW default, with is very small maybe

 64k

Under pane 2, import export switches, under libraries, the middle text entry box

 liblua

Save the project.

Hit compile and all being well lua.exe has appeared.

Run it, should pick up the the dll and off you go. A good first test, assuming you can find the source files

 > dofile("factorial.lua")

This loads and executes a script with that name.

If you want you can add another target luac.exe, with is a compiler to binary for scripts. A compiled script is roughly the same size but load slightly faster and a known free from syntax errors. For most users this utility is of little use.

Personal tools