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

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

3.2.1 Compiling and linking in UNIX environment

Organization of this subsection
(1) Compiling
(2) Linking

(1) Compiling

Write the CUP in an ANSI C compliant C language. Compile the CUP's C source program to create an object file. Use the cc command for TP1/Client/W.

Table 3-2 shows the compiler options that must be set.

Table 3-2 Required compiler options (in HI-UX/WE2, HP-UX, and non-Windows environments)

TP1/Client version Option Meaning
TP1/Client/W -Aa Compile as ANSI C.

Example
C language UAP source programs:
  • cupmain.c (main function)
  • cupfnc1.c (internal function 1)
  • cupfnc2.c (internal function 2)
Compile each source program as shown below.
TP1/Client/W
 
cc -c -I/usr/include -Aa cupmain.c
cc -c -I/usr/include -Aa cupfnc1.c
cc -c -I/usr/include -Aa cupfnc2.c
 
When the source programs contain dc_xxx_xxx_s functions that support a multi-thread environment, enter commands as shown below.
 
xlc_r -c cupmain.c
xlc_r -c cupfunc1.c
xlc_r -c cupfunc2.c
 
Executing the above cc commands produces the following object files:
  • cupmain.o (object file containing the main function)
  • cupfnc1.o (object file containing internal function 1)
  • cupfnc2.o (object file containing internal function 2)

(2) Linking

The CUP executable file is created by linking the files shown below. Use the cc command for TP1/Client/W.

Example command lines for linking the above files are shown below.

Example
Creating the CUP executable file "example"
  • Main function object file
    cupmain.o
  • Internal function object files
    cupfncl.o and cupfnc2.o
Link the files as shown below.
TP1/Client/W
 
cc -o example cupmain.o cupfnc1.o cupfnc2.o
   -L/usr/lib -lclt
 
To create a CUP that supports a multi-thread environment, link the files by using the following command:
 
xlc_r -o example cupmain.o cupfnc1.o cupfnc2.o -L/usr/lib -lclt
 
The -L option can be omitted.