Preparing C programs

Precompiled C programs are found in the /opt/mqm/samp/bin directory. To build a sample from source code, use the C compiler in /bin/cc, for example:

/bin/cc -o <yourprog> <yourprog>.c -lmqm -lmqmcs -lmqmzse \
-lnet -lnsl -lsocket -ldl
Note:
The backslash (\) represents the continuation of the line.

C compiler flags

The order of the libraries specified is important. The following is an example of how to build the sample program amqsput0:

/bin/cc -o <amqsput0> <amqsput0>.c -lmqic -lmqmcs -lmqmzse \
-lnet -lnsl -lsocket -ldl -lc

This links with the client library -lmqic, so allows you to use the programs on a machine which has only the WebSphere MQ client for GIS installed.

If you use the other version of the compiler (/usr/ucb/cc), your application may compile and link successfully. However when you run it, it will fail when it attempts to connect to the queue manager.

Linking libraries

You need to link your programs with the appropriate library provided by WebSphere MQ.

You must link to one or more of the following libraries:

Library file Program/exit type
libmqm.so Server for C
libmzse.so For C
libmqic.so Client for C
libmqmcs.so Client for C

Notes:

  1. If you are writing an installable service (see WebSphere MQ System Administration Guide for further information), you need to link to the libmqmzf.so library.

  2. If you are producing an XA switch load file for external coordination by an XA-compliant transaction manager such as IBM CICS, Transarc Encina, or Novell Tuxedo, you need to link to the libmqmxa.a library.


© IBM Corporation 1993, 2002. All Rights Reserved