z/OS® UNIX C/C++ programs
with source code in z/OS UNIX files or data sets must
be compiled to create output object files residing either in z/OS UNIX files
or data sets.
Both the SCEERUN and the SCEERUN2 libraries must be available when
compiling in the z/OS UNIX System Services environment.
You can compile and bind application source code at one time, or
compile the source and then bind at another time with other application
source files or compiled objects.
As of z/OS V1R6, there are
two utilities that enable you to invoke the compiler. The c89 utility
enables compiler invocation using host environment variables and the
xlc utility uses an external configuration file to control the invocation
of the compiler. The following list highlights the differences between
the xlc and c89 utilities:
- xlc utility uses the c89 utility to invoke the binder and the
assembler and it has no direct interface to them
- xlc does not require that lp64 and xplink be
explicitly specified as options on the command line for both the compile
and the bind step; it uses the _64 and _x command name suffixes to
ensure 64-bit and XPLINK compiles and binds
- xlc utility supports -q options syntax as the
primary method of specifying options on the command line
- xlc utility is unaffected by the value assigned to the STEPLIB
environment variable in the z/OS UNIX Systems Services session;
it obtains the STEPLIB from the configuration file
- xlc utility supports the same command names as the c89 utility
(cc, c89, c++,
and cxx), so the PATH environment variable must
contain the path to the xlc bin directory
ahead of the /bin directory if the xlc version
of cc, c89, c++,
and cxx is required
- xlc utility does not support -WI for invoking IPA; it uses -O4
and -O5 or -qipa as the mechanism for invoking
IPA
The c89 utility and xlc utility invoke the binder by default, unless
the output file of the link-editing phase (-o option)
is a PDS, in which case the prelinker is used.
For information on customizing your environment to compile and
bind in the z/OS UNIX System
Services environment,
see Environment variables or Setting up a configuration file.
Use the c89 utility
or the xlc utility to compile and
bind a C application
program from the
z/OS shell.
The syntax is:
c89 [-options …] [file.c …] [file.a …] [file.o …] [-l libname]
where:
- options
- are c89 or xlc options.
- file.c
- is a source file. Note that C source files have a file extension
of lowercase c.
- file.o
- is an object file.
- file.a
- is an archive file.
- libname
- is an archive library.
The c89 and
xlc utilities support IPA. For information on how to invoke the IPA
compile step using c89 or xlc,
refer to Invoking IPA using the c89 or xlc utilities.
You can also use the cc command to compile a
C application program from the z/OS shell.
For more information, see c89 — Compiler invocation using host environment variables or
the xlc command names described in xlc — Compiler invocation using a customizable configuration file.
Use the
c++ command to compile and
bind a
C++ application
program from the
z/OS shell.
The syntax for
c++ is:
c++ [-options …] [file.C …] [file.a …] [file.o …] [-l libname]
where:
- options
- are C++ options.
- file.C
- is a source file. Note that C++ files have a file extension of
uppercase C. The _CXX_CXXSUFFIX environment variable or cxxsuffix configuration
file attribute can also be used to control which extensions are
recognized as C++ file source extensions.
- file.o
- is an object file.
- file.a
- is an archive file.
- libname
- is an archive library.
Another name for the c++ command is cxx.
The cxx command and the c++ command
are identical. You can use cxx instead of c++ in
all the examples that are shown in this topic. If you are using
the xlc utility, you can also use the xlc and the xlc++ commands,
which are identical to c++ and cxx.
For a complete list of c++ options, and for
more information on cxx, see c89 — Compiler invocation using host environment variables and xlc — Compiler invocation using a customizable configuration file.
Note: You can compile and bind application
program source and objects from within the shell using the c89 or
xlc utilities. If you use one of these utilities, you must keep
track of and maintain all the source and object files for the application
program. You can use the make utility to maintain your z/OS UNIX System
Services application
source files and object files automatically when you update individual
modules. The make utility will only compile files that have changed
since the last make run.
For more information on using the make utility, see Archive and make utilities and z/OS UNIX System Services Programming Tools.