6 The Oz DLL Builder: oztool

oztool facilitates the creation of native functors (see Part VI of ``Application Programming'' and ``Interfacing to C and C++''). A native functor is a DLL, i. e. a library that is dynamically loaded by the Oz emulator and interfaces with it. Creating a native functor often involves complicated compilation and linking technicalities (e. g. options). oztool takes care of these details for you.

oztool c++ ...

Instead of calling the C++ compiler directly, you should invoke it through oztool. The advantages are: it calls the right compiler, with the right options, and also extends the include search path to find the Mozart specific includes such as mozart.h. Normally, you would compile a native functor implemented in foo.cc using:

oztool c++ -c foo.cc

oztool cc ...

Same idea, but for the C compiler

oztool ld ...

Instead of calling the linker directly, you should also invoke it through oztool. Again, the advantages are that it calls the right linker, with the right options. Normally, you would create a DLL from foo.o as follows:

oztool ld -o foo.so foo.o

oztool platform

The default Resolution mechanism locates architecture specific DLLs as follows: If the system needs a native functor called (abstractly) foo.so, then it will look for a DLL called foo.so-linux-i486 on a Linux machine, foo.so-solaris-sparc on a Solaris machine, or foo.so-win32 on a Windows machine, etc... Thus, when you create a DLL, you should install it with a name where the machine's architecture is appended. Invoking oztool platform simply prints out the appropriate architecture name for your machine. In this respect, oztool helps you write portable Makefiles: to create a DLL from file foo.cc you would normally invoke:

oztool c++ -c foo.cc
oztool ld -o foo.so-`oztool platform` foo.o

6.1 Windows Environment Variables

Under Windows, oztool supports the use of several compilers as described in Chapter 5 of ``Interfacing to C and C++''. Furthermore, when using the GNU compiler suite, the exact name of the compilers and linker to invoke can be set by the environment variables shown in the following table with their default values.

Environment Variable

Default Value


gcc -mno-cygwin


g++ -mno-cygwin


g++ -mno-cygwin

These values correspond to the compilers used to build Mozart. The above binaries are provided by the Cygwin gcc package. Note that using a different compiler can lead to problems, as described in Section 5.1 of ``Interfacing to C and C++''.

Denys Duchier, Leif Kornstaedt and Christian Schulte
Version 1.4.0 (20080702)