Compiling a Hello World program to test the compiler installation

To test the product installation and the critical search paths, build and run a simple program.

For example:
  1. Create the following COBOL program:
    [hello.cbl]
    000100 IDENTIFICATION DIVISION.
    000200 PROGRAM-ID.  HELLO.
    000300 AUTHOR.      JOE PROGRAMMER.
    000400 ENVIRONMENT DIVISION.
    000500 DATA DIVISION.
    000600 PROCEDURE DIVISION.
    000700 MAINLINE.
    000800     DISPLAY 'Hello World!'.
    000900     STOP RUN.
    
  2. Compile the test program. For example:
    If you have set up the short invocation commands, enter the following command:
    cob2 hello.cbl -o hello
    If you have not set up the short invocation commands, enter the following command:
    installation_path/cobol/1.2.0/usr/bin/cob2 hello.c -o hello
    
    where installation_path is the installation location of the compiler packages. If the compiler is installed to the default location, installation_path is /opt/ibm/.
  3. Run the program:
    ./hello

    The expected result is that "Hello World!" is displayed on the screen.

  4. Check the exit code of the program:
    echo $?

    The result should be zero.