5 Creating object files under Windows 95/NT

TODO: check this

Currently there is no oztool available for Windows 95/NT to compile and create a DLL (dynamic link library). Consult your C compilers documentation on how to create DLLs. When loading a DLL, Oz will automatically call a C function named OZ_linkFF to do a certain special linking step needed on the Windows platform. This function is defined in the file mozart.c contained in the include subdirectory of the Oz installation directory. So you have to compile mozart.c and include it into the DLL. You also have to explicitely export all the functions you want to call from Oz (including OZ_linkFF) from the DLL.

Dynamic linking has been testet using Watcom version 10.6 and MS Visual C++ version 4.0. In the following we shortly describe how to proceed on each of these compilers to create the DLL named getenv.dll for the example above.

TODO: For some strange reason that I don't know the DLL has to have the suffix .so-win32-i486. So after you've created getenv.dll as described below, rename it to getenv.so-win32-i486 which then can be loaded into Oz as described above.

5.1 Watcom

First create a file named getenv.lnk with the following contents:

system nt_dll initinstance terminstance 
name getenv.so-win32-i486
export _BIgetenv 
export _OZ_linkFF 
export _oz_init_module 
file getenv,mozart

Note that you have to prepend a _ to each of the functions, that you want to export.

Then compile the source files and create the DLL using the following commands (replace OZHOME by the directory where Oz has been installed):

wcc386 -zq -bd -IOZHOME\include mozart.c
wpp386 -zq -bd -IOZHOME\include getenv.cc
wlink @getenv

5.2 Microsoft Visual C++

First create a file named getenv.def with the following contents:

LIBRARY getenv 
EXPORTS 
  OZ_linkFF
  BIgetenv

Compilation and creation of the DLL is done using the following commands:

cl -IOZHOME\include -c mozart.c
cl -IOZHOME\include -c -Tp getenv.cc
link /def:getenv.def /dll mozart.obj getenv.obj


Michael Mehl, Tobias Müller, Christian Schulte and Ralf Scheidhauer
Version 1.0.1 (19990218)