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:
- 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.
- 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:
whereinstallation_path/cobol/1.2.0/usr/bin/cob2 hello.c -o hello
installation_path
is the installation location of the compiler packages. If the compiler is installed to the default location,installation_path
is /opt/ibm/. - Run the program:
./hello
The expected result is that
"Hello World!"
is displayed on the screen. - Check the exit code of the program:
echo $?
The result should be zero.