Preparing C programs

Precompiled C programs are supplied in the /opt/mqm/samp/bin directory. To build a sample from source code, use a supported compiler (see Appendix A, Language compilers and assemblers for more information).

To compile, for example, the sample program amqsput0:

  1. export LIB=/opt/mqm/lib:$LIB
  2. Ensure the environment is set to use the correct versions of the compiler software and man pages:
      export PATH=/opt/SUNWspro/bin:$PATH
      export MANPATH=/opt/SUNWspro/man:/usr/man:$MANPATH
      export LD_LIBRARY_PATH=  \
      /opt/SUNWspro/lib:/$OPENWINHOME/lib:$LD_LIBRARY_PATH
    
  3. Compile the program (the order of the libraries specified is important):
      cc -o <amqsput0> <amqsput0>.c -mt -lmqm -lmqmcs -lmqmzse   \
      -lsocket -lnsl -ldl
    

If you wish to compile a DCE application, use the following:

  cc -o <amqsput0> <amqsput0>.c -mt -lmqm -lmqmcs_d -lmqmzse   \
  -ldce -lthread -lsocket -lnsl -ldl

If you use the unsupported 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.

If you want to use the programs on a machine which has only the WebSphere MQ client for Solaris installed, recompile the programs to link them with the client library instead:

  cc -o <amqsput0> <amqsput0>.c -lmqic -lmqmcs -lsocket

To build an WebSphere MQ client application that uses DCE, enter:

cc -o <amqsput0> <amqsput0>.c -mt -lmqic -lmqmcs_d -lmqmzse \
-ldce -lm -lpthread -lsocket -lc -lnsl -ldl

Linking libraries

You must link with the WebSphere MQ libraries that are appropriate for your application type:

Program/exit type
Library files
Server for C
libmqm.so, libmqmcs.so,
and libmqmzse.so
Client for C
libmqic.so, libmqmcs.so,
and libmqmzse.so
Server for C with DCE
libmqm.so, libmqmcs_d.so,
and libmqmzse.so
Client for C with DCE
libmqic.so, libmqmcs_d.so,
and libmqmzse.so

Notes:

  1. If you are writing an installable service (see WebSphere MQ System Administration Guide for further information), 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, link to the libmqmxa.a library.

  3. To run the sample Encina program, link against the following libraries in addition to the libraries listed above.

    Also, link against libmqmcs_d.so instead of libmqmcs.so, in addition to the Encina and DCE libraries:



© IBM Corporation 1993, 2002. All Rights Reserved