Program loading order and run-time system usage for native COBOL

Note: The following information applies to native code only.

In dynamically bound applications , the order in which programs are loaded affects which run-time systems are searched for and the use of the run-time system. For example:

.exe Files and First .dll Files

A "first" COBOL .dll file is the first loaded component of an application that needs a COBOL run-time system for execution. In the following description, the term ".exe file" also implies the term "first .dll file".

When the application runs, the .exe file locates and loads a compatible run-time system, depending on how the application was linked. If the application was:

  • Linked normally (that is, without using dynamic binding), the .exe file looks for a run-time system on the path specified by the PATH environment variable. If more than one run-time system is installed, this can cause a conflict.
  • Linked using dynamic binding, the .exe file dynamically binds to a run-time system by consulting the Windows registry for installed and compatible run-time systems. If a run-time system cannot be found, then the current setting of the PATH environment variable is used to load a default run-time system.

Compatible Run-time Systems

When you create a dynamically bound executable file you can specify what level of run-time system the executable file is allowed to work with. This enables you to specify that the executable can work with any newer version of the run-time system than the one you linked it with, or whether the executable is restricted to the current release of the run-time system only.

The level and threading mode of a run-time system is checked as follows:

  • The level of the run-time system is identified as a version number in the registry. For example, for version 6.0 of the COBOL development system, the run-time system level is 6.0.
  • The path used to load the run-time system is determined from the registry value:
    \HKEY_LOCAL_MACHINE\SOFTWARE
    \Micro Focus\Visual COBOL\x.y\COBOL\Environment\PATH

    where:

    x.y
    is the installed version of the COBOL system.

    If the executable was restricted to the current release level when it was created, x.y must be greater than or equal to the development system version with which the executable was created.

  • If none of the above techniques works, the default setting of PATH is used to load the run-time system.

In any case, when the run-time system has been loaded a version and type check is performed and any incompatibilities reported.

Further .dll Files

When a second or further .dll file is loaded into a same process, it must bind to the existing run-time system within the process. If you create an application that does not use dynamic binding, then you must make sure that all programs in an application are linked to the same run-time system, otherwise conflicts could occur that would result in the application failing.

If you use dynamic binding when you create the second or further .dll files in your application then you can specify that they will either bind to any loaded and compatible run-time system, or will fail cleanly with informative diagnostic messages.