Preparing COBOL programs
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:
- Change directory to $COBDIR/coblib:
cd $COBDIR/coblib
- Note:
- By default, COBDIR is /opt/lib/cobol.
- Make a backup copy of liblist:
cp liblist liblist.saved- Edit the liblist file using a standard UNIX editor like vi:
vi liblist- 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:
- 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.
- Define the location of the copybooks which declare the MQI structures:
export COBCPY="/opt/mqm/inc"- 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 - Compile the program:
cob -vxP amq0put0.cbl -lmqmcb -lmqm -lmqmcs -lmqmzse