Page 1 of 1

How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 4:21 am
by chan
Could anyone give me a minimal example of how to compile/link/run a simple C++ program (Hello World says) using JCL? I read the documentation from IBM but it was way too complex. They listed so many options that confused me. Thanks in advance.

Re: How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 5:16 am
by steve-myers

Re: How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 5:27 am
by chan
Hi Steve,
Sorry posting a very similar question, but I honestly read that. But at the moment, with my limited knowledge, I really don't quite understand all of that. To me, an example would be a tremendous help since from there I can perform trial-error to see what works what does not.
I'm currently working alone on the Marist z/OS, just a research project for one of my professors, and I'm not studying at Marist College. No one in my school have any knowledge about mainframe whatsoever. So it's really frustrated to look for help, especially during this Winter break. I hope you understand my situation.

Re: How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 9:04 am
by steve-myers
If you are going to use z/OS you must learn some JCL. It really is not all that hard - though I must admit I've been using it for more than 40 years. My response to your initial post suggested you look at several possible cataloged procedures, which you can easily do with ISPF. Most compiler oriented cataloged procedure imply their purpose in the characters at the end of the procedure name.
  • C - The procedure will compile a program
  • L - The procedure will lin kedit a program
  • G - The procedure will execute ("go")a program
So a procedure xxxCLG will compile, link edit, and execute a program. Something like xxxCG will compile, and in one step run a linking loader and execute a program.

A "linking loader," which is probably a strange concept to you, prepares executable code in storage without preparing a load module. The idea has been around for a long time in mainframes because the mainframe linkage editor was fairly slow, and the overhead to run a separate linkage editor step was very high. A few software vendors came up with the idea of a linking loader, and IBM produced its own, which kind of blew the vendor provided linking loaders out of the water. In the 1990s, when IBM replaced the 1960s derived linkage editor with the Binder, rather than continue with a linking loader as a separate program, as was done in the 1960s, the linking loader was included with the Binder, though it appears to be a separate program.

In most shops, the IBM procedures, along with many shop specific procedures are in a data set called 'SYS1.PROCLIB. Look there first.

Re: How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 10:37 am
by chan
Hi Steve,
Thanks a lot, I will definitely go over all those things you mentioned above. By the way, could you suggest me some good books for z/OS and JCL?

Re: How to compile/link/run a C/C++ program with JCL?

PostPosted: Thu Dec 20, 2012 11:04 am
by delorimier
chan wrote:By the way, could you suggest me some good books for z/OS and JCL?

You may look at this one: Gary DeWard Brown, z/OS JCL, Fifth Edition (Wiley, 2002).