Precompiling, compiling, and linking the samples
Learn about precompiling, compiling, and linking samples in C and COBOL.
Precompile the .SQC files (in C) and .SQB files (in COBOL), and bind them against the appropriate database to produce the .C or .CBL files. To do this, use the typical method for the database product.
Precompiling in C
db2 connect to MQBankDB db2 prep AMQSXAS0.SQC db2 connect reset db2 connect to MQBankDB db2 prep AMQSXAB0.SQC db2 connect reset db2 connect to MQFeeDB db2 prep AMQSXAF0.SQC db2 connect reset
Precompiling in COBOL
db2 connect to MQBankDB db2 prep AMQ0XAS0.SQB bindfile target ibmcob db2 bind AMQ0XAS0.BND db2 connect reset db2 connect to MQBankDB db2 prep AMQ0XAB0.SQB bindfile target ibmcob db2 bind AMQ0XAB0.BND db2 connect reset db2 connect to MQFeeDB db2 prep AMQ0XAF0.SQB bindfile target ibmcob db2 bind AMQ0XAF0.BND db2 connect reset
Compiling and linking
The following sample commands use the symbols DB2TOP and MQ_INSTALLATION_PATH. DB2TOP represents the installation directory for the Db2 product. MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.- On AIX, the directory path is:
/usr/lpp/db2_05_00
- On Windows systems, the directory
path depends on the path chosen when installing the product. If you chose the default settings the
path is this:
c:\sqllib
Note: Before issuing the link command on Windows systems, ensure that the LIB environment variable contains paths to the Db2 and IBM MQ libraries. Copy the following files into a temporary directory:
- The amqsxag0.c file from the IBM MQ installation Note: This file can be found in the following directories:
- On UNIX and Linux systems:
MQ_INSTALLATION_PATH/samp/xatm
- On Windows systems:
MQ_INSTALLATION_PATH\tools\c\samples\xatm
- On UNIX and Linux systems:
- The .c files that we have obtained by precompiling the .sqc source files, amqsxas0.sqc, amqsxaf0.sqc, and amqsxab0.sqc.
- The files util.c and util.h from your Db2 installation. Note: These files can be found in the
directory:
DB2TOP/samples/c
Build the object files for each .c file using the following compiler command for the platform that we are using:
- AIX
xlc_r -I MQ_INSTALLATION_PATH/inc -I DB2TOP/include -c -o FILENAME.o FILENAME.c
- Windows systems
cl /c /I MQ_INSTALLATION_PATH\tools\c\include /I DB2TOP\include FILENAME.c
Build the amqsxag0 executable file using the following link command for the platform that we are using:
- AIX
xlc_r -H512 -T512 -L DB2TOP/lib -ldb2 -L MQ_INSTALLATION_PATH/lib -lmqm util.o amqsxaf0.o amqsxab0.o amqsxag0.o -o amqsxag0
- Windows systems
link util.obj amqsxaf0.obj amqsxab0.obj amqsxag0.obj mqm.lib db2api.lib /out:amqsxag0.exe
Build the amqsxas0 executable file using the following compiling and linking commands for the platform that we are using:
- AIX
xlc_r -H512 -T512 -L DB2TOP/lib -ldb2 -L MQ_INSTALLATION_PATH/lib -lmqm util.o amqsxas0.o -o amqsxas0
- Windows systems
link util.obj amqsxas0.obj mqm.lib db2api.lib /out:amqsxas0.exe
Additional information
If we are working on AIX and want to access Oracle, use the xlc_r compiler and link to libmqm_r.a.
Parent topic: Database coordination samples