Compaq AAQ2G1FTK Marine Radio User Manual


 
Developing Compaq COBOL Programs
1.2 Developing Programs on Tru64 UNIX
Compiles the file
mainprog.cob
, which contains the main program
Uses
ld
to link both the main program and object files into an executable
program file named
calc
The files can also be compiled separately, as follows:
% cobol -c array_calc.cob
% cobol -c calc_aver.cob
% cobol -o calc mainprog.cob array_calc.o calc_aver.o
In this case, the
-c
option prevents linking and retains the
.o
files. The first
command creates the file
array_calc.o
. The second command creates the file
calc_aver.o
. The last command compiles the main program and links the object
files into the executable program named
calc
.
If your path definition includes the directory containing
calc
, you can run the
program by simply typing its name:
% calc
You can compile multiple source files by concatenating them:
% cat proga1.cob proga2.cob proga3.cob > com1.cob
% cat progb1.cob progb2.cob > com2.cob
% cobol -c com1.cob com2.cob
The resulting file names are com1.o and com2.o. The OpenVMS Alpha equivalent
to this is:
$ COBOL proga1+proga2+proga3,progb1+progb2
1.2.2.6 Debugging a Program
To debug a program using the Ladebug Debugger, compile the source files
with the
-g
flag to request additional symbol table information for source line
debugging in the object and executable program files. The following
cobol
command also uses the
-o
flag to name the executable program file
calc_debug
:
% cobol -g -o calc_debug mainprog.cob array_calc.cob calc_aver.cob
To debug an executable program named calc_debug, type the following command:
% ladebug calc_debug
For more information on running the program within the debugger, see the
Ladebug Debugger Manual.
1.2.2.7 Output Files: Object, Executable, Listing, and Temporary Files
The output produced by the
cobol
command includes:
An object file, if you specify the
-c
flag on the command line
An executable file, if you omit the
-c
flag
A listing file, if you specify the
-V
flag
If the environment variable TMPDIR is set, the value is used as the directory for
temporary files.
You control the production of these files by specifying the appropriate flags on
the
cobol
command line. Unless you specify the
-c
flag, the compiler generates a
single temporary object file, whether you specify one source file or multiple source
files separated by blanks. The
ld
linker is then invoked to link the object file into
one executable image file.
1–16 Developing Compaq COBOL Programs