Preparing C programs in AIX
This topic contains information about linking libraries necessary to prepare C programs on AIX®.
Precompiled C programs are supplied in the MQ_INSTALLATION_PATH
/samp/bin
directory. Use the ANSI compiler and run the following commands. For
further information about programming 64 bit applications, see Coding
standards on 64-bit platforms.
MQ_INSTALLATION_PATH
represents the high-level directory in which WebSphere MQ is installed.
$ xlc_r -o amqsput_32 amqsput0.c -IMQ_INSTALLATION_PATH
/inc -LMQ_INSTALLATION_PATH
/lib -lmqm
where amqsput0
is a
sample program.
$ xlc_r -q64 -o amqsput_64 amqsput0.c -IMQ_INSTALLATION_PATH
/inc -LMQ_INSTALLATION_PATH
/lib64 -lmqm
where amqsput0
is a sample program.If you are using the VisualAge® C/C++ compiler
for C++ programs you must include the option -q namemangling=v5
to get all the WebSphere® MQ symbols resolved
when linking the libraries.
If you want to use the programs on a machine that has only the WebSphere MQ MQI client for AIX installed,
recompile the programs to link them with the client library (-lmqic
) instead.
Linking libraries
- Link your programs with the appropriate library provided by WebSphere MQ.
In a non-threaded environment, link to one of the following libraries:
Library file Program/exit type libmqm.a Server for C libmqic.a & libmqm.a Client for C In a threaded environment, link to one of the following libraries:
Library file Program/exit type libmqm_r.a Server for C libmqic_r.a & libmqm_r.a Client for C For example, to build a simple threaded WebSphere MQ application from a single compilation unit run the following commands.
For 32-bit applications:
where$ xlc_r -o amqsputc_32_r amqsput0.c -I
MQ_INSTALLATION_PATH
/inc -LMQ_INSTALLATION_PATH
/lib -lmqm_ramqsput0
is a sample program.For 64-bit applications:
where$ xlc_r -q64 -o amqsputc_64_r amqsput0.c -I
MQ_INSTALLATION_PATH
/inc -LMQ_INSTALLATION_PATH
/lib64 -lmqm_ramqsput0
is a sample program.If you want to use the programs on a machine that has only the WebSphere MQ MQI client for AIX installed, recompile the programs to link them with the client library (
-lmqic
) instead.Note:- If you are writing an installable service (see the Administering for further information), you need to link to the libmqmzf.a library in a non-threaded application and to the libmqmzf_r.a library in a threaded application.
- 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.a (or libmqmxa64.a if your transaction manager treats the 'long' type as 64 bit) and libmqz.a libraries in a non-threaded application and to the libmqmxa_r.a (or libmqmxa64_r.a) and libmqz_r.a libraries in a threaded application.
- You need to link trusted applications to the threaded WebSphere MQ libraries. However, only one thread in a trusted application on WebSphere MQ on UNIX and Linux® systems can be connected at a time.
- You must link WebSphere MQ libraries before any other product libraries.