Previous Topic Next topic Print topic


Compiled File Types

Before your program can be run or debugged, it must be in a form that can be executed. The Compiler can produce the following types of files:

Executable code
You produce executable code by compiling and linking in one step.

An executable file has a filename extension of .exe (Windows) or no filename extension (UNIX).

To create executable code, you need either a COBOL project or a COBOL remote project. Select Project > Properties > Micro Focus > Build Configuration and create or edit a configuration, choosing a Target types option of All Executable Files or Single Executable File.

Object code
Object code files are created when you build your project . The object code file is not executable. It requires linking with the run-time system to produce an executable file.

By default, object code files have the extension .obj (Windows) or .o (UNIX).

Object code files must be linked to create .exe or .dll files (Windows) or executable, callable shared object or shared library files (UNIX).

Java bytecode
Java bytecode can be executed on a Java Virtual Machine (JVM).

You create a JVM COBOL project in the IDE in a similar way as you create any COBOL project and many of the configuration options are common to both. Select File > New > COBOL JVM Project.

A Java bytecode file has a filename extension of .class.

Intermediate code
Restriction: It is not possible to build JVM projects to .int files.
Intermediate code files are usually for testing and debugging. The Compiler creates the intermediate code file during its first phase, when it checks the program syntax. The Compiler also creates a dictionary file, which is used by the debugger. Intermediate code files compile quickly.

Intermediate code files have the extension .int.

.int files are dynamically loadable, and don't need to be linked into a system executable. You can ship them to your users as executable files, but we recommend that you use .exe files and .dll files for this.

To compile to intermediate code files, set the following properties:
  1. Click Project > Properties > Micro Focus > Build Configuration and create or edit a configuration, choosing a Target types option of All Int/Gnt Files.
  2. Click Project > Properties > Micro Focus > Project Settings > COBOL and make sure Compile to .gnt is not selected.
Tip: You can check Override Project Settings in the build configuration properties and specify to produce a set of either .int or .gnt files for a specific build configuration. To produce a mixture of .int and .gnt files from one build configuration, modify the individual file properties - right-click on individual files and check Override Project Settings. Then, either check or clear Compile to .gnt to compile to .int or .gnt, respectively.
Generated code
Restriction: You cannot build JVM projects as .gnt files.
The Compiler creates the generated code, on request, during its second phase. Generated code is slower to compile than intermediate code but the resulting code runs faster.

Use generated code files for testing and debugging. As generated code runs faster than intermediate code, it can be useful in debugging for large programs, or for debugging programs where the distance between breakpoints is large, for example.

Generated code files have the extension .gnt.

.gnt files are dynamically loadable, and don't need to be linked into a system executable. You can ship them to your users as executable files, but we recommend that you use .exe files and .dll files for this.

To compile generated code files set the following properties:
  1. Click Project > Properties > Micro Focus > Build Configuration and create or edit a configuration, choosing a Target types option of All Int/Gnt Files.
  2. Click Project > Properties > Micro Focus > Project Settings > COBOL and select Compile to .gnt.
Dynamic Link Libraries (Windows) or Callable shared objects (UNIX)
Dynamic Link Libraries (Windows) or Callable shared objects (UNIX) are dynamically loaded at run time when required, that is, when referenced as a main entry point (for example, by run (Windows) or cobrun (UNIX)) or by the COBOL CALL syntax. When all the entry points in a Dynamic Link Library (Windows) or a callable shared object (UNIX) have been canceled then the file is unloaded, releasing any memory used.

This behavior is similar to .int and .gnt code but is different to linked shared libraries and system executables, which are always loaded at process start-up, whether they are used or not. Further, the code and memory used by shared libraries and system executables are only unloaded when the process terminates.

A Dynamic Link Library (Windows) or a callable shared object (UNIX) can contain more than one COBOL program and can also contain other language programs, such as C and C++. Dynamic Link Libraries (Windows) or callable shared objects (UNIX) can also be linked with third party object files or shared libraries. This behavior is similar to system executables and shared libraries but differs from .int and .gnt files, where each file corresponds to a single COBOL program.

A Dynamic Link Library (Windows) has a filename extension of .dll.

A callable shared object file (UNIX) has a filename extension of .so.

To create Dynamic Link Libraries (Windows) or callable shared objects (UNIX), you need either a COBOL project or a COBOL remote project. Select Project > Properties > Micro Focus > Build Configuration and create or edit a configuration, choosing a Target types option of All Native Library Files or Single Native Library File.

Bundling intermediate or generated code files

You can bundle .int files and .gnt files in Micro Focus library files. The advantages of this are:

  • It can simplify the packaging of files for users, as it reduces the number of files to be shipped.
  • When your program calls a subprogram stored in a library file, the library file and all the programs loaded in it, is loaded into memory. This can make program execution faster.

A library file has the file extension .lbr.

For example, given the following programs in our application:
Figure 1. Programs in application
Programs in application

ProgC and ProgD could be compiled as generated code files, and then placed in a library file, mylib.lbr. When ProgA calls ProgC, mylib.lbr would be loaded into memory, also loading progc.gnt and progd.gnt. You would need to ship proga.gnt, progb.gnt, and mylib.lbr, as well as a trigger program.

To package the .int and .gnt files into an .lbr file, set the following properties:

  1. Click Project > Properties > Micro Focus > Build Configuration and create or edit a configuration, choosing a Target types option of All Int/Gnt Files.
  2. Select Package as .lbr.
Next time you build your project, the project builds .int or .gnt files as normal, and also compiles them all into an .lbr file.
Restriction: You cannot compile .lbr files for JVM or mainframe projects.
Previous Topic Next topic Print topic