# How to use YACL with Watcom C++

Last update: June 2, 1997

This file provides directions on how to build YACL and its demo programs using Watcom C++.

## Building YACL

Caveat: YACL requires Watcom C++ 10.0a or later, because earlier versions of Watcom C++ do not provide adequate support for templates.

0. Create and change into the directory where you want to install YACL. For example, under DOS or OS/2:

`md c:\yacl c: cd \yacl`

1. Unzip the file YACL.ZIP, preserving directories. For example:

`unzip yacl.zip`

or, if you use pkunzip:

`pkunzip -d yacl.zip`

2. Set the environment variable YACLPATH to point to the directory in which yacl was unzipped, e.g.,

`set YACLPATH=c:\yacl`

3. Modify the control file control\watcomc.ctl. In that file: (a) Set the variable WTCPATH to point to the root directory of your Watcom C++ system, e.g.,

`set WTCPATH=e:\watcom`

By default, this path is set to the value of the environment variable WATCOM. If you have this environment variable set to point to the Watcom directory, you need not do step 3a. (b) If you are using Watcom C++ 10.5 or later, uncomment the definition of the variable WTC_10_5_OR_LATER. If you are using version 10.0, make sure this definition is commented out.

4. If you want to build the Windows or Windows NT versions, you must copy ctl3d.h into the Watcom headers directory. For example, assuming that your Watcom compiler lives in e:\watcom and YACL is in c:\yacl, you would type:

For 16-bit Windows:

`copy c:\yacl\lib\windows\ctl3d.h e:\watcom\h\win`

For 32-bit Windows NT:

`copy c:\yacl\lib\windows\ctl3d.h e:\watcom\h\nt`

(You might actually have to copy ctl3d3d.dll into your WINNT35\SYSTEM32 directory; I'm not sure NT can always find the DLL otherwise.) In addition, you must create a .LIB for CTL3D, using the following commands:

For 16-bit Windows:

`md lib\windows`

`cd lib\windows`

`wlib ctl3d.lib +ctl3d.dll`

`cd ..\..`

For 32-bit Windows NT:

`md lib\win32`

`cd lib\win32`

`wlib ctl3d32.lib +ctl3d32.dll`

`cd ..\..`

5. Build the libraries. CD into the directory you chose in step 0 and issue the make command as below:

`wmake -f watcomc.mak YACLPLATFORM=DOS`

to build the DOS version, or

`wmake -f watcomc.mak`

to build the Windows, Windows NT or OS/2 version. If you build under OS/2, the wmake command invoked in an OS/2 command window builds the OS/2 version, and if invoked in a DOS window, builds a DOS or Windows version.

Under Windows NT, invoking this command in a Windows NT command window (i.e., using CMD.EXE, not COMMAND.COM) causes it to build the NT version. You can build the 16-bit Windows version under NT by typing the command

`wmake -f watcomc.mak YACLPLATFORM=WINDOWS`

6. Poke around in the directory structure under basedemo and uidemo; build and try out the programs there using the makefiles provided. Each demo program is in a separate directory with a Watcom-specific makefile called watcomc.mak. I have provided makefiles for most of the base demos but not all because most, if not all, the base classes are heavily used in the UI classes.

Don't build the basedemo programs for Windows; it's a lot easier to test them from the command line (e.g. DOS, OS/2 or Windows NT window).

You can also build a debug version of the library via the command

`wmake -f watcomc.mak DEBUG=-DDEBUG`

## Known problems

The template support in Watcom C++ 10.0a is still buggy. So if you attempt to instantiate your own templates using the YACL containers, you might get lots of syntax errors. This happens, for example, if you try to instantiate a Set of Points in `ui/containr.cxx`. I don't know if the latest release of the compiler (the 10.5 version) fixes these problems. The reason why 10.0a compiles YACL now, and it didn't before, is just that I found a workaround for its bugs and restructured the YACL code.

Generally, though, Watcom C++ seems to produce smaller executables, particularly under OS/2. I'd guess this is because of the linker option "eliminate" which doesn't seem to be available for other compilers.

Watcom C++ sometimes doesn't do type casts properly. For example, the following statement

`(CL_Interval&) VScroller->Model() = CL_Interval(0, 0);`

has to be parenthesized under Watcom:

`((CL_Interval&) VScroller->Model()) = CL_Interval(0, 0);`

The Ctl3d library and the -zz option. Under Windows 3.1 and Windows NT 3.51, you can use the Ctl3d library to produce 3-d dialog effects. To do this, however, there is a somewhat ugly aliasing to be done (see uidemo/wtcappmk.ctl). Try using the -zz option to get around this if necessary. Using -zz under Windows NT 4.0, however, causes the Watcom linker to fail to link the UI demos -- it gives an error that there is a "multiply defined start symbol cstrwwt in clib3r.lib" (whatever that means).

Watcom C++ under OS/2 and Windows NT. Under OS/2 and Windows NT, the Watcom linker is unable to retrieve the main program from the UI library; don't know why. It complains that a start address is not found. This does not happen under Windows, which is weird. The workaround I use is to explicitly include `ui/mainprog.obj` in the linker command. You can see this in `uidemo/wtcappmk.ctl`, which is included by all the uidemo makefiles.

Shared libraries (DLLs). You can build YACL's base and I/O libraries as DLLs using Watcom C++, via the make command

`wmake -f watcomc.mak BUILD_DLL=1`

These work fine, with the base demos. However, even though the UI library builds successfully as a DLL, the UI demos do not run at all (i.e., they exit immediately). I don't yet know why, and am still investigating. All assistance is welcome.