OpenTP1 Version 7 TP1/Client User's Guide TP1/Client/W, TP1/Client/P

[Contents][Index][Back][Next]

3.2.2 Compiling and linking in Windows environments

Organization of this subsection
(1) Procedure
(2) Compiling and linking

(1) Procedure

The following figure shows the procedure for creating a CUP.

Figure 3-1 Procedure for creating a CUP

[Figure]

(2) Compiling and linking

(a) Compiling the source program

Use the Microsoft C compiler (version 6.0 or later) to create CUP object files in the Windows environment. Use the cc command for compilation.

The compiler options required when normal object libraries are used differ from those required when DLLs are used. The following tables show the options required in these two cases.

Table 3-3 Required compiler options (Windows environment and normal object libraries)

TP1/Client version Option Meaning
TP1/Client/P /AM Specifies the memory model.
/AM: Medium memory model
(The TP1/Client/P library uses the medium memory model for Windows environments.)
/Zp Packs structures.
/Gw Creates Windows-specific prolog and epilog.
/DDCCLTFAR Defines the pointer as a far pointer.

Note
When the XATMI interface facility is used, /DDCCLTDLL must also be specified.

Table 3-4 Required compiler options (Windows environment and DLLs)

TP1/Client version Option Meaning
TP1/Client/P /Zp Packs the structure.
/Gw Generates the prolog and epilog dedicated to Windows.
/DDCCLTFAR Defines the pointer as a far pointer.
/DDCCLTDLL Develops a header file provided by TP1/Client/P for a DLL.

Example command lines for compiling a source program are shown below.

Example
C language UAP source programs:
  • cup.c (main function)
  • cupsub1.c (internal function 1)
  • cupsub2.c (internal function 2)
Compile each source program as shown below.
Normal object library
 
CL /AM /Zp /Gw /DDCCLTFAR /c cup.c
CL /AM /Zp /Gw /DDCCLTFAR /c cupsub1.c
CL /AM /Zp /Gw /DDCCLTFAR /c cupsub2.c
When the XATMI interface facility is used, /DDCCLTDLL must also be specified.
DLL
 
CL /Zp /Gw /DDCCLTFAR /DDCCLTDLL /c cup.c
CL /Zp /Gw /DDCCLTFAR /DDCCLTDLL /c cupsub1.c
CL /Zp /Gw /DDCCLTFAR /DDCCLTDLL /c cupsub2.c
 
Executing the above CL commands produces the following object files:
  • cup.obj (object file containing the main function)
  • cupsub1.obj (object file containing internal function 1)
  • cupsub2.obj (object file containing internal function 2)
(b) Creating the resource definition file

In this example, an icon is defined as a resource. Create the resource definition file cup.rc as follows:

 
CUPI   ICON cup.ico
 

CUPI is an arbitrary name given to the icon. Use the SDKPAINT.EXE tool included in Windows SDK to create the icon file (cup.ico).

(c) Compiling resources

Compile the resource definition file (cup.rc) as follows using the Windows SDK resource compiler:

 
rc /r cup.rc
 

Executing the above rc command creates the resource file cup.res.

(d) Creating a module definition file

Create the example module definition file cup.def as follows:

 
NAME        CUPEXEC
DESCRIPTION 'CUP SAMPLE PROGRAM'
EXETYPE     WINDOWS
STUB        'WINSTUB.EXE'
CODE PRELOAD MOVEABLE
DATA PRELOAD MOVEABLE
HEAPSIZE     1024
STACKSIZE    8192
 

Specify 8192 or more for STACKSIZE.

(e) Linking the CUP

Use the LINK command to link the files shown below and create the CUP executable file.

# CLTCNV32.LIB is also required to use the character code converter.