Executable file formats

You must compile your program to an executable before it can be run or debugged. This topic summarizes the different types of executable file that the Micro Focus COBOL Compiler can produce. It also gives recommendations to help you choose which file format is most appropriate for your applications and summarizes how you can package files together by bundling intermediate and generate code files into Micro Focus library files.

Executable code (.exe)

You can compile procedural COBOL, and native OO COBOL code to .exe.

Executable code can be produced by compiling and linking in one step.

An executable file has no filename extension.

Java bytecode (.class files)

You can compile procedural COBOL and JVM COBOL to Java bytecode. Java bytecode (.class files) can run under the Java Virtual Machine.

The Compiler supports generation of procedural COBOL code to Java .class files and offers object-oriented extensions to the COBOL language.

JVM COBOL compiles to Java bytecode (.class files) which can run under the Java Virtual Machine.

The Compiler the supports generation of procedural COBOL code to Java .class files and also offers object-oriented extensions to the COBOL language.

Dynamic Link Libraries or Callable shared objects
Dynamic link libraries or callable shared objects are dynamically loaded at run time when required; that is, when referenced as a main entry point (for example, by run or cobrun ) or by the COBOL CALL syntax. When all the entry points in a dynamic link library or a callable shared object 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 or a callable shared object can contain more than one COBOL program and can also contain other language programs, such as C and C++. Dynamic link libraries or callable shared objects 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 callable shared object file has a filename extension of .so.

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 .o.

Object code files must be linked to create executable, callable shared object or shared library files.

Intermediate code
Intermediate code files have the extension .int and are usually used for testing and debugging. The Compiler creates the intermediate code file during its first phase, when it checks the program syntax. Intermediate code files compile quickly.

.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.

Generated code
Generated code files have the extension .gnt and are created by the Compiler, on request, during its second phase. Generated code is slower to compile than intermediate code but the resulting code runs faster.

.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.

Recommendations

This section contains general guidance and recommendations about when to use each of the different file formats.

Micro Focus recommends the use of standard format executables. Standard executable formats, such as .dll or .exe, are also optimized for the target platform and can be digitally signed. These formats can also contain more than one program.

.int files have the advantage of being portable across different hardware platforms. They have the disadvantage of not being optimized for any target architecture and will typically execute more slowly than code that has been generated for a specific platform.

.gnt files are optimized for a specific chipset. They typically execute faster than .int code. Micro Focus recommends the use of generated executables for best application performance.

.gnt files are not locked by the operating system while executing. This means that new files can be overlaid, but this is not considered good practice.

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 simplifies 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 are 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
Program overview diagram

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 includes them all into an .lbr file.
Restriction: You cannot compile .lbr files for JVM or mainframe projects.