Preparing C programs in HP-UX

This topic contains information to consider when preparing C programs in HP-UX; with examples for the IA64 (IPF) platform.

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

Work in your normal environment. Precompiled C programs are supplied in the MQ_INSTALLATION_PATH/samp/bin directory.

For further information about programming 64 bit applications see Coding standards on 64-bit platforms.

To use TLS, IBM MQ MQI clients on HP-UX must be built using POSIX threads.

Some examples to consider are:


IA64 (IPF) platform

Build examples of amqsput0, cliexit, and srvexit on IA64(IPF) platform.

The following example builds the sample program amqsput0 as a client application in a non-threaded 32 bit environment:
c89 -Wl,+b,: +e -D_HPUX_SOURCE -o amqsputc_32 amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib -L/usr/lib/hpux32 -lmqic
The following example builds the sample program amqsput0 as a client application in a threaded 32 bit environment:
c89 -mt -Wl,+b,: +e -D_HPUX_SOURCE -o amqsputc_32_r amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib -L/usr/lib/hpux32 -lmqic_r -lpthread
The following example builds the sample program amqsput0 as a client application in a non-threaded 64 bit environment:
c89 +DD64 +e -D_HPUX_SOURCE -o amqsputc_64 amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqic
The following example builds the sample program amqsput0 as a client application in a threaded 64 bit environment:
c89 -mt +DD64 +e -D_HPUX_SOURCE -o amqsputc_64_r amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqic_r -lpthread
The following example builds the sample program amqsput0 as a server application in a non-threaded 32 bit environment:
c89 -Wl,+b,: +e -D_HPUX_SOURCE -o amqsput_32 amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib -L/usr/lib/hpux32 -lmqm
The following example builds the sample program amqsput0 as a server application in a threaded 32 bit environment:
c89 -mt -Wl,+b,: +e -D_HPUX_SOURCE -o amqsput_32_r amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib -L/usr/lib/hpux32 -lmqm_r -lpthread
The following example builds the sample program amqsput0 as a server application in a non-threaded 64 bit environment:
c89 +DD64 +e -D_HPUX_SOURCE -o amqsput_64 amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqm
The following example builds the sample program amqsput0 as a server application in a threaded 64 bit environment:
c89 -mt +DD64 +e -D_HPUX_SOURCE -o amqsput_64_r amqsput0.c -I MQ_INSTALLATION_PATH/inc
  -L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqm_r -lpthread
The following example builds a client exit cliexit in a non-threaded 32 bit environment:
c89 +e +z -c -D_HPUX_SOURCE -o cliexit.o cliexit.c -I MQ_INSTALLATION_PATH/inc
ld +b: -b cliexit.o +ee MQStart -o /var/mqm/exits/cliexit_32 -L MQ_INSTALLATION_PATH/lib \
-L/usr/lib/hpux32 -lmqic
The following example builds a client exit cliexit in a threaded 32 bit environment:
c89 -mt +e +z -c -D_HPUX_SOURCE -o cliexit.o cliexit.c -I MQ_INSTALLATION_PATH/inc
ld +b: -b cliexit.o +ee MQStart -o /var/mqm/exits/cliexit_32_r -L MQ_INSTALLATION_PATH/lib \
-L/usr/lib/hpux32 -lmqic_r -lpthread
The following example builds a client exit cliexit in a non-threaded 64 bit environment:
c89 +DD64 +e +z -c -D_HPUX_SOURCE -o cliexit.o cliexit.c -I MQ_INSTALLATION_PATH/inc
ld -b cliexit.o +ee MQStart -o /var/mqm/exits64/cliexit_64 \
-L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqic
The following example builds a client exit cliexit in a threaded 64 bit environment:
c89 -mt +DD64 +e +z -c -D_HPUX_SOURCE -o cliexit.o cliexit.c -I MQ_INSTALLATION_PATH/inc
ld -b cliexit.o +ee MQStart -o /var/mqm/exits/cliexit_64_r \
-L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqic_r -lpthread
The following example builds a server exit srvexit in a non-threaded 32 bit environment:
c89 +e +z -c -D_HPUX_SOURCE -o srvexit.o srvexit.c -I MQ_INSTALLATION_PATH/inc
ld +b: -b srvexit.o +ee MQStart -o /var/mqm/exits/srvexit_32 -L MQ_INSTALLATION_PATH/lib \
-L/usr/lib/hpux32 -lmqm
The following example builds a server exit srvexit in a threaded 32 bit environment:
c89 -mt +e +z -c -D_HPUX_SOURCE -o srvexit.o srvexit.c -I MQ_INSTALLATION_PATH/inc
ld +b: -b srvexit.o +ee MQStart -o /var/mqm/exits/srvexit_32_r -L MQ_INSTALLATION_PATH/lib \
-L/usr/lib/hpux32 -lmqm_r -lpthread
The following example builds a server exit srvexit in a non-threaded 64 bit environment:
c89 +DD64 +e +z -c -D_HPUX_SOURCE -o srvexit.o srvexit.c -I MQ_INSTALLATION_PATH  MQ_INSTALLATION_PATH/inc
ld -b srvexit.o +ee MQStart -o /var/mqm/exits64/srvexit_64 \
-L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqm
The following example builds a server exit srvexit in a threaded 64 bit environment:
c89 -mt +DD64 +e +z -c -D_HPUX_SOURCE -o srvexit.o srvexit.c -I MQ_INSTALLATION_PATH/inc
ld -b srvexit.o +ee MQStart -o /var/mqm/exits/srvexit_64_r \
-L MQ_INSTALLATION_PATH/lib64 -L/usr/lib/hpux64 -lmqm_r -lpthread


Linking libraries

You need to link your programs with one of the libraries provided by IBM MQ.

The following table shows which library to use in different environments:
Hardware platform Threaded or non-threaded environment Program/exit type Library file
IA64 (IPF) Threaded Server & Client for C libmqm_r.so
IA64 (IPF) Threaded Client for C libmqic_r.so
IA64 (IPF) Non-threaded Server & Client for C libmqm.so
IA64 (IPF) Non-threaded Client for C libmqic.so
Note:
  1. We cannot link to more than one library. That is, we cannot link to both a threaded and a non-threaded library at the same time.
  2. If you are writing an installable service (see the Administer for further information), you need to link to the libmqmzf.sl library.
  3. If you are producing an application for external coordination by an XA-compliant transaction manager such as IBM TXSeries® Encina, or BEA Tuxedo, you need to link to the libmqmxa.sl (or libmqmxa64.sl if your transaction manager treats the 'long' type as 64 bit) and libmqz.sl libraries in a non-threaded application and to the libmqmxa_r.sl (or libmqmxa64_r.sl ) and libmqz_r.sl libraries in a threaded application.
  4. You must link IBM MQ libraries before any other product libraries.