How to install COBOL compiler and run cobol program in ubuntu

Sponsored Link
COBOL is one of the oldest programming languages, primarily designed by Grace Hopper. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments.

Install COBOL compiler in ubuntu

Open the terminal and run the following comamnd

sudo apt-get install open-cobol

Once the installation is completed you can check the cobol compiler details using the following comamnds

whereis cobc


cobc: /usr/bin/cobc /usr/share/man/man1/cobc.1.gz

which cobc



Compile the cobol program

Compile the HelloWorld which will create the HelloWorld executable.

cobc -free -x -o helloworld-exe helloworld


helloworld helloworld-exe*

-free – use free source format. Without this option cobol program requires certain format.
-x – build executable program.
-o FILE – place the output file into the specified FILE.

Execute the cobol Program

Execute by mentioning the program name.


Hello World!

Via TheGeekstuff

Sponsored Link

You may also like...

1 Response

  1. dave knight says:

    The open-cobol compiler installed on a raspberry pi (raspbian stretch) does not like the “comment” line starting with an asterisk (*):

    dmk@pi3b:~ $ cobc -free -x -o helloworld-exe helloworld.cobol
    helloworld.cobol:3: Error: syntax error, unexpected ‘*’, expecting “end of file”
    dmk@pi3b:~ $

    Don’t know about other ports…

Leave a Reply

Your email address will not be published. Required fields are marked *