Before you can run a program, you have to compile the source code.
By default, the Compiler compiles your program without any intervention. You can configure the project to be built in a specific way, such as specifying types of target files to build, the target platform and so on.
You can configure the compilation using the following techniques:
- Compiler directives. You can control the way programs are compiled by using Compiler directives.
You use directives to control the way the Compiler behaves. Normally, you need only a few directives. Most of the time, you use the default values. Note that setting some directives affects the default setting of other directives. For example, setting one directive might automatically unset another directive, and some directive settings are mutually exclusive.
- 32- and 64-bit compilation. You can produce 32- and 64-bit applications from the same source code by setting the
Platform Target option in the IDE. You can also compile bit-specific output from the command line by
using the
cobol command from the 32-bit or 64-bit command prompt.
- Linked resources. Linked resources enable you to link to sources that are outside the project, thereby saving you from copying the sources into the project, and enabling to share resources with others.
- Copybook locations. You can specify the location of the copybooks that your program refers to, if you keep them in different directories from the program. You can do this in the IDE, and also through the COBCPY environment variable.
- Temporary files used during compilation. Before compiling, you must ensure there is enough free space for the Compiler's temporary work files. You can specify the location where the Compiler puts its temporary files.
- Techniques for compiling quickly. Large applications comprising many programs can take significant time to compile. You can use various techniques to increase the speed of compilation.
The Compiler records errors with severity levels ranging from information messages to fatal errors which stop the Compiler working.
When you compile as native code, the Compiler can produce executable code directly or object code. Object code is not executable, and has to be linked to the run-time system to create an executable file.
Compiling from the command line
Using the command line, you can
compile without linking using the
cobol command, or
compile and link your program in one step using the
cbllink utility.
You can either specify all the information required on the command line, or use the Compiler prompts.