Skip to content

Building and Running hello.cbl

In our sample project, the compiler configuration is designed to:

  • Set the -o compiler flag to create object files to be created in the .\object folder.
  • Set the -t compiler flag to create listing files the .\lst folder.
  • Set the -I compiler flag to locate copy files in the .\copy folder.
  • Set the -g compiler flag to cause debugging information to be added to the object files, so they can be run in debug mode.

Our Runtime configuration should:

  • Set the COB_LIBRARY_PATH to allow the runtime to locate the compiled object.
  • Set the COB_FILE_PATH to cause the runtime to locate files in the .\data folder.

Project>Properties>COBOL Properties

Click on the Project folder in the Navigator Window to select it. Right click, and select Properties from the right-click dropdown menu to open the Properties dialog Window.

In the menu on the left, select COBOL Properties. In the COBOL Properties dialog, click Enable source settings to enable the setting of compiler flags through the Compiler Properties sub-headings in the panel on the left.

COBOL Properties

  • On the Standard Options screen, set the -o compiler flag to .\object.
  • On the Standard Options screen, set the -t compiler flag to .\lst.
  • On the Environment>Copy Files screen, set the -I compiler flag to .\copy.
  • On the DevOps Tools>Degugging Tools screen, set -g compiler flag.

Click Apply, and then click OK to save your selections, and close the Properties dialog Window.

Standardize a Run Configuration

When you select the Run function from the main toolbar, or from the main menubar, the standard Developer Studio Behavior is to create and exec script, and then run it.

A sample exec script for hello.dll:

       CALL %COBOLITDIR%\setenv_cobolit.bat
       cmd.exe /c start /wait cobcrun hello

The exec script first runs a Pre-run script, which by default is set to setenv_cobolit.bat, and then runs the program you wish to execute. The Pre-run script can be customized through the Customize Setup dialog screen.

If all of the programs in your project can be run with the same environment variables, then it is best to set the environment variables in your Pre-run script. In an example in which a program, hello.cbl, has been compiled with the –o .\object compiler flag, the runtime requires that the environment variable COB_LIBRARY_PATH be set to .\object.

A standardized run configuration would include a Pre-run script that contained the instruction:

  • (Windows) SET COB_LIBRARY_PATH=.\object
  • (Linux) export COB_LIBRARY_PATH=./object

Customize a Run Configuration

You can accept the default Pre-run Script, which is the COBOL-IT setup script, and then include environment variable settings in a Run Configuration.

To create a customized Run Configuration for hello.cbl:

Right-click on the COBOL program hello.cbl in the Navigator Window.

Select Run As…. from the right-click dropdown menu, and then select Run Configurations… to open the Run Configurations dialog Window.

Run Configurations

The Run Configurations dialog Window

The Run Configurations dialog Window consists of a tree structure on the left panel, and a multi-tabbed Window in the right panel.

Create a new Runtime Configuration, and assign it a name:

Select COBOL Program and click on the New toolbar button above the tree structure on the left panel. On the Run Configurations dialog Window, change the Name from New Configuration to hello.cbl. Click on the Apply button to change the name of the configuration in the tree structure on the left.

Hello.cbl Run Configurations

Set runtime environment variables on the Environment tab

The Environment tab is where we will set the runtime environment variables that we need to produce the desired behaviors. On the Environment tab, click on the New button to open the New Environment Variable dialog screen. Create new environment entries for COB_LIBRARY_PATH and COB_FILE_PATH.

Click Apply, and Close, to save your settings, and close the Run Configurations Dialog Screen.

Environment Variables

We are now ready to review the Clean, Build, Run, and Debug operations.

Back to top