How to install COBOL compiler and run cobol program in ubuntu
Sponsored Link
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
output
cobc: /usr/bin/cobc /usr/share/man/man1/cobc.1.gz
which cobc
output
/usr/bin/cobc
Compile the cobol program
Compile the HelloWorld which will create the HelloWorld executable.
cobc -free -x -o helloworld-exe helloworld
ls
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.
./helloworld-exe
Hello World!
Via TheGeekstuff
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…