Monday, October 18, 2010

How to create and run COBOL Program in Linux ^_^

1. Write a Hello World Cobol Program

Create the JohnPaulSample program using the Vim editor as shown below.

$ sudo gedit JohnPaulSample

Note:

Types of Editor in Linux

1. Gedit
2. Kedit
3. Emacs
4. Anjuta
5. Nano
6. Vim
7. JEdit (Open Source Java Code Editor)

My Sample Program in Cobol

IDENTIFICATION DIVISION.
PROGRAM-ID. JohnPaulSampleProgram.
PROCEDURE DIVISION.
DISPLAY 'Hello John Paul!'.
STOP RUN.

Note: Comment in Cobol starts with *.
2. Make sure Cobol Compiler is installed on your system

Make sure Cobol compiler is installed on your system as shown below.

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


Note:

whereis - command in linux for looking faster for a specific path or directory of file or package.




$ which cobc
/usr/bin/cobc

Installing COBC compiler

If you don’t have cobol compiler, install it as shown below.

$ sudo apt-get install open-cobol

Note

sudo - super user do. (Admin privileges)



3. Compile the cobol program trought Terminal

Compile the JohnPaulSample which will create the JohnPaulSample executable.

$ cobc -free -x -o JohnPaulSample-exe JohnPaulSample

$ ls
JohnPaulSample JohnPaulSample-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.

4. Execute the cobol Program

Execute by mentioning the program name.

$./JohnPaulSample-exe
Hello John Paul!

2 comments:

  1. Yo, paul.. can i ask, I have a Fedora 14 server linux, is already install for the game server and the games is ready, so my problem is connecting into QT-Developments for 'C'. can gave me some idea for the linux server?

    Hope you teach me

    Sherwin

    ReplyDelete
  2. Your game supported 2D or 3D graphics?

    - You can install trough fedora the follwoing QT Components.

    QGraphicsView

    QGLWidget

    QTimer

    Additional, for NVIDIA support video graphics card support you can use

    PhysX API

    ReplyDelete