Preparing COBOL programs

Notes to users

  1. 32 bit COBOL copy books are installed in the following directory:
    /opt/mqm/inc/cobcpy32
    and symbolic links are created in:
    /opt/mqm/inc
  2. 64 bit COBOL copy books are installed in the following directory:

    /opt/mqm/inc/cobcpy64
  3. In the following examples set COBCPY to:
    /opt/mqm/inc/cobcpy32
    for 32 bit applications, and:
    /opt/mqm/inc/cobcpy64
    for 64 bit applications.

Before preparing your COBOL programs, check with your system administrator that the COBOL compiler is set up to link with the correct C libraries. By default, the COBOL compiler Version 3.2 links to 3.0 SPARCompiler C libraries. For example, to update the compiler to link with SPARCompiler Version 4.0, ensure that your system administrator has completed the following:

  1. Change directory to $COBDIR/coblib:
      cd $COBDIR/coblib
    Note:
    By default, COBDIR is /opt/lib/cobol.
  2. Make a backup copy of liblist:
      cp liblist liblist.saved
  3. Edit the liblist file using a standard UNIX(R) editor such as vi:
      vi liblist
  4. Change all references from SC3.0 to SC4.0.

The COBOL compiler is now set up for you to compile COBOL programs.

Precompiled COBOL programs are supplied in the /opt/mqm/samp/bin directory. Use the Micro Focus compiler from the directory /opt/bin to build a sample from source code.

To compile, for example, the sample program amq0put0:

  1. Ensure that the environment is set:
      export COBDIR=/opt/lib/cobol
      export PATH=/opt/bin:$PATH
      export LD_LIBRARY_PATH=$COBDIR/coblib:$LD_LIBRARY_PATH
    Note:
    The above assumes that COBOL is installed in the default directories.
  2. Define the location of the copybooks that declare the MQI structures:
      export COBCPY="<COBCPY>"
  3. Link your program with one of the following libraries when building the application:
    Library file Program/exit type
    libmqmcb.so Server for COBOL
    libmqicb.so Client for COBOL
  4. Compile the program:
      cob -vxP amq0put0.cbl -lmqmcb -lmqm -lmqmcs -lmqmzse