running applications under z/OS UNIX System Services" /> Building and running applications under z/OS UNIX System Services

 

Building and running applications under z/OS UNIX System Services

To build an application under the UNIX System Services shell, 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 data sets thlqual.SCSQLOAD, thlqual.SCSQAUTH, and one of the language specific data sets, such as thlqual.SCSQANLE.

 

Sample commands to compile the HELLO WORLD C++ sample program

  1. Copy the sample into the HFS using the TSO oput command, or use FTP. The rest of this example assumes that you have copied the sample into a directory called /u/fred/sample, and named it imqwrld.cpp.

  2. Log into the UNIX System Services shell, and change to the directory where you placed the sample.

  3. Set up the C++ compiler so that it can accept the DLL side-deck and .cpp files as input:

    /u/fred/sample:> export _CXX_EXTRA_ARGS=1
    /u/fred/sample:> export _CXX_CXXSUFFIX="cpp"

  4. Compile and link the sample program. The following command links the program with the batch side-decks; the RRS batch side-decks can be used instead. The \ character is used to split the command over more than one line. Do not enter this character; enter the command as a single line:

    /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.

We can also 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. Set up the environment 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 z/OS UNIX System Services Programming Tools for more information on using make.

 

Sample commands to run the HELLO WORLD C++ sample program

  1. Log into the UNIX System Services shell, and change to the directory where you built the sample.

  2. Set up the STEPLIB environment variable to include the WebSphere MQ data sets:

    /u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQLOAD
    /u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQAUTH
    /u/fred/sample:> export STEPLIB=$STEPLIB:thlqual.SCSQANLE

  3. Run the sample:

    /u/fred/sample:> ./imqwrld