Working in 32-bit and 64-bit Modes | Using the Compiler |
This chapter introduces you to creating programs.
As you saw in the section Executable File Types in the chapter Packaging Applications, you can create five types of executable file:
To create an executable file you need to use the Cob utility. Cob invokes the Compiler and/or the system linker for you, depending on the specified output executable file.
The Compiler compiles a program in two phases:
The system linker converts native object code into a callable shared object, system executable or shared library file.
Cob can take source code, intermediate code or native object code as input. It can also take C or C++ source code as input for certain executable file types. The steps Cob takes to create the various types of executable file are shown in the following diagram:
The sections below give you general information on compiling programs using the Cob utility. For information on using the Cob utility see the chapter COBOL System Interface (Cob). If you are working in 64-bit mode, you should also see the chapter Working in 32-bit and 64-bit Modes.
You can create an intermediate code file using the Compiler directly. There is no need to link the program. However, to run the program you need to do one of the following:
For more details see the chapter Packaging Applications.
You can compile the source code file myprog.cbl to intermediate code as follows:
cob -i myprog.cbl
This creates an intermediate code file called myprog.int.
The command:
cob -a myprog.cbl
also creates an intermediate code file, along with files for use by Animator.
You create a generated code file using the Compiler. There is no need to link the program. However, to run the program you need to do one of the following:
For more details see the chapter Packaging Applications.
You can compile the source code file myprog.cbl to generated code as follows:
cob -ug myprog.cbl
This creates a generated code file called myprog.gnt,and Animator information files.
You can also create a .gnt file from an .int file using:
cob -ug myprog.int
The -g option produces files for use by Animator.
Creating a callable shared object involves two steps:
Both steps are done using Cob.
To run the program you need to do one of the following:
For more details see the chapter Packaging Applications.
You can compile the source code file myprog.cbl to a callable shared object as follows:
cob -z myprog.cbl
This creates a callable shared object called myprog.so.
The command:
cob -zg myprog.cbl
creates a callable shared object, and files for use by Animator.
You can also create callable shared objects from .int files and native object code files (.o) files using:
cob -z myprog.int
or:
cob -z myprog.o
See the chapter Callable Shared Objects for more information.
Creating a system executable file involves two steps:
Both steps are done using Cob.
For example, if the file myprog.cbl contains the source program, you can compile and link the program to a system executable file in one step, as follows:
cob -xg myprog.cbl
This creates a system executable file called myprog.
The -g option produces files for use by Animator.
Creating a shared library file involves two steps:
Both steps are done using Cob.
For example, if the file myprog.cbl contains the code you want to create as a shared library you can compile and link the program to a shared library file in one step, as follows:
cob -Zg myprog.cbl
The -Z option creates a shared library file called libmyprog.so.
The -g option produces files for use by Animator.
A shared library file is not executable itself. It must be linked into a system executable using the -l flag on the Cob command line. For example:
cob -x myapp.o -L. -lmyprog
creates a system executable myapp that loads libmyprog.so when it is run.
Many options are available for controlling the way your program is compiled. These options are specified using directives when you invoke the Compiler. You can enter Compiler directives individually on the command line, or you can create default directives which are then invoked as a group either automatically, or from the command line, or from within the source code.
For normal operation you need to know about and use very few directives. In the majority of cases you will use the default values. The directives are described in detail in the chapter Directives for Compiler.
Many directives direct the Compiler to create code which is compatible with other COBOL compilers. More details of these can be found in your Compatibility Guide. The directives you are most likely to use are those that define the output produced by the Compiler.
For more information about setting directives, see the section Directives in the chapter Using the Compiler.
For more information on compiling and linking programs, see the following chapters in this manual :
For information on Compiler directives, see the chapter Directives for Compiler.
Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Working in 32-bit and 64-bit Modes | Using the Compiler |