[Linux]

Preparing COBOL programs in Linux

Learn about preparing COBOL programs in Linux® and preparing COBOL programs using IBM® COBOL for Linux on x86 and Micro Focus COBOL.

MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.

  1. 32-bit COBOL copy books are installed in the following directory:
    MQ_INSTALLATION_PATH/inc/cobcpy32
    
    and symbolic links are created in:
    MQ_INSTALLATION_PATH/inc
    
  2. On 64-bit platforms, 64 bit COBOL copy books are installed in the following directory:
    MQ_INSTALLATION_PATH/inc/cobcpy64
    
  3. In the following examples set COBCPY to:
    MQ_INSTALLATION_PATH/inc/cobcpy32
    
    for 32-bit applications, and:
    MQ_INSTALLATION_PATH/inc/cobcpy64
    
    for 64-bit applications.

You need to link your program with one of the following:

Library file Program/exit type
libmqmcb.so Server for COBOL
libmqicb.so Client for COBOL
libmqmcb_r.so Server for COBOL (threaded application)
libmqicb_r.so Client for COBOL (threaded application)

Preparing COBOL programs using IBM COBOL for Linux on x86

Sample COBOL programs are supplied with IBM MQ. To compile such a program, enter the appropriate command from the following list:

32-bit non-threaded server application
$ cob2 -o amq0put0 amq0put0.cbl -q"BINARY(BE)" -q"FLOAT(BE)" -q"UTF16(BE)" -L MQ_INSTALLATION_PATH/lib -lmqmcb -ICOBCPY_VALUE
32-bit non-threaded client application
$ cob2 -o amq0put0 amq0put0.cbl -q"BINARY(BE)" -q"FLOAT(BE)" -q"UTF16(BE)" -L MQ_INSTALLATION_PATH/lib -lmqicb -ICOBCPY_VALUE
32-bit threaded server application
$ cob2_r -o amq0put0 amq0put0.cbl -q"BINARY(BE)" -q"FLOAT(BE)" -q"UTF16(BE)" -qTHREAD -L MQ_INSTALLATION_PATH/lib -lmqmcb_r -ICOBCPY_VALUE
32-bit threaded client application
$ cob2_r -o amq0put0 amq0put0.cbl -q"BINARY(BE)" -q"FLOAT(BE)" -q"UTF16(BE)" -qTHREAD -L MQ_INSTALLATION_PATH/lib -lmqicb_r -ICOBCPY_VALUE

Preparing COBOL programs using Micro Focus COBOL

Set environment variables before compiling your program as follows:

export COBCPY=COBCPY_VALUE
export LIB= MQ_INSTALLATION_PATH lib:$LIB
To compile a 32-bit COBOL program, where supported, using Micro Focus COBOL, enter:

$ cob32 -xvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib -lmqmcb Server for COBOL
$ cob32 -xvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib -lmqicb Client for COBOL
$ cob32 -xtvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib -lmqmcb_r Threaded Server for COBOL
$ cob32 -xtvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib -lmqicb_r Threaded Client for COBOL
To compile a 64-bit COBOL program using Micro Focus COBOL, enter:

$ cob64 -xvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib64 -lmqmcb Server for COBOL
$ cob64 -xvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib64 -lmqicb Client for COBOL
$ cob64 -xtvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib64 -lmqmcb_r Threaded Server for COBOL
$ cob64 -xtvP amqsput.cbl -L MQ_INSTALLATION_PATH/lib64 -lmqicb_r Threaded Client for COBOL
where amqsput is a sample program

See the Micro Focus COBOL documentation for a description of the environment variables that you need.