You can write C++ programs for three of the environments that WebSphere MQ for z/OS supports:
When you have written the C++ program for your WebSphere MQ application, you have to create an executable application by compiling, pre-linking, and link-editing it.
WebSphere MQ C++ for z/OS is implemented as z/OS DLLs for the IBM C++ for z/OS language. Using DLLs, you have to concatenate the supplied definition side-decks with the compiler output at pre-link time. This allows the linker to check your calls to the WebSphere MQ C++ member functions.
To build a WebSphere MQ for z/OS C++ application, you need to create and run JCL. Use the following procedure:
In addition, for CICS applications you need to:
Be sure to specify the /cxx compiler option.
To run batch or RRS batch programs, the libraries thlqual.SCSQAUTH and thlqual.SCSQLOAD must be included in the STEPLIB, or JOBLIB data set concatenation.
To run a CICS program, you must first get your system administrator to define it to CICS as a WebSphere MQ program and transaction. You can then run it in the usual way.
WebSphere MQ for z/OS supplies three sample programs, together with JCL to run them. The programs are described in Sample programs.
The sample applications are supplied in source form only. The files
are:
Table 4. z/OS sample program files
Sample | Source program ( in library thlqual. SCSQCPPS ) | JCL ( in library thlqual. SCSQPROC ) |
---|---|---|
HELLO WORLD | imqwrld | imqwrldr |
SPUT | imqsput | imqsputr |
SGET | imqsget | imqsgetr |
To run the samples, you need to compile and link-edit them as with any C++ program (see Building an application on z/OS). Use the supplied JCL to construct and run a batch job. You must initially customize the JCL, by following the commentary included with it.
In order to build an application under the UNIX System Services shell, you must give the compiler access to the WebSphere MQ include files (located in thlqual.SCSQC370 and thlqual.SCSQHPPS), and link against two of the DLL side-decks (located in thlqual.SCSQDEFS). At runtime, the application needs access to the WebSphere MQ datasets thlqual.SCSQLOAD, thlqual.SCSQAUTH, and one of the language specific datasets, such as thlqual.SCSQANLE.
/u/fred/sample:> export _CXX_EXTRA_ARGS=1 /u/fred/sample:> export _CXX_CXXSUFFIX="cpp"
/u/fred/sample:> c++ -o imqwrld -I "//'thlqual.SCSQC370'" \ -I "//'thlqual.SCSQHPPS'" imqwrld.cpp \ "//'thlqual.SCSQDEFS(IMQS23DM)'" "//'thlqual.SCSQDEFS(IMQB23DM)'"
For more information on the TSO oput command, refer to the z/OS UNIX System Services Command Reference.
It is also possible to use the make utility to simplify building C++ programs. Here is a sample makefile to build the HELLO WORLD C++ sample program. It separates the compile and link stages. The environment should be set up as in step 3 above before running make.
flags = -I "//'thlqual.SCSQC370'" -I "//'thlqual.SCSQHPPS'" decks = "//'thlqual.SCSQDEFS(IMQS23DM)'" "//'thlqual.SCSQDEFS(IMQB23DM)'" imqwrld: imqwrld.o c++ -o imqwrld imqwrld.o $(decks) imqwrld.o: imqwrld.cpp c++ -c -o imqwrld $(flags) imqwrld.cpp
Refer to the z/OS UNIX System Services Programming Tools manual for more information on using make.
/u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQLOAD /u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQAUTH /u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQANLE
/u/fred/sample:> ./imqwrld