Does a standalone cobol program need link editing?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
RoyW
New Member
Posts: 7
Joined: Sun Jun 21, 2015 11:00 pm

Does a standalone cobol program need link editing?

Post by RoyW »

Hi,

I know that for preparing a COBOL program before executing using a RUN JCL, we need to compile the program and then link edit it so that we have a load module which can be executed using the JCL. But I have the confusion that if we have only one cobol program which is stand alone, then do we need to link edit it before it can be executed?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Does a standalone cobol program need link editing?

Post by William Collins »

Yes, you do.

The compiler produces an "object deck". An object-deck is not executable.

The linkage-editor/binder is producing a loadmodule, using object-decks and loadmodules as input, even when there is only one of the former and none of the latter.

With COBOL V5, loadmodules are no longer used (instead exclusively Program Objects are produced) but the principle is the same. The compiler does not produce code that is directly executable.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Does a standalone cobol program need link editing?

Post by Robert Sample »

If you look at the pseudo-assembler code produced by the COBOL compiler, you will notice that COBOL has a number of run-time routines that are invoked (the DISPLAY statement has a run-time routine, for example, so every DISPLAY statement will use the system routine). These run-time routines need to be included into the load module before the program will successfully execute. This is one of the reasons every COBOL program has to go through the linkage editor / binder before it can be executed. As was mentioned, another reason is that the COBOL compiler produces object code and not executable code.
RoyW
New Member
Posts: 7
Joined: Sun Jun 21, 2015 11:00 pm

Re: Does a standalone cobol program need link editing?

Post by RoyW »

William Collins wrote:With COBOL V5, loadmodules are no longer used (instead exclusively Program Objects are produced) but the principle is the same. The compiler does not produce code that is directly executable.
Then how do we execute the programs now in JCL? Are we not going to use PGM=pgm in the JCL now? We are still not using COBOL V5.
RoyW
New Member
Posts: 7
Joined: Sun Jun 21, 2015 11:00 pm

Re: Does a standalone cobol program need link editing?

Post by RoyW »

Robert Sample wrote:If you look at the pseudo-assembler code produced by the COBOL compiler, you will notice that COBOL has a number of run-time routines that are invoked (the DISPLAY statement has a run-time routine, for example, so every DISPLAY statement will use the system routine). These run-time routines need to be included into the load module before the program will successfully execute. This is one of the reasons every COBOL program has to go through the linkage editor / binder before it can be executed. As was mentioned, another reason is that the COBOL compiler produces object code and not executable code.
Thanks Robert.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Does a standalone cobol program need link editing?

Post by William Collins »

Don't worry, you still execute programs in the same way.
With COBOL V5, loadmodules are no longer used (instead exclusively Program Objects are produced) but the principle is the same
.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”