Building C++ programs on IBM i
Build IBM MQ C++ programs on IBM i using the ILE C++ compiler.
IBM ILE C++ for IBM i is a native compiler for C++ programs. The following instructions describe how to use this compiler to create IBM MQ C++ applications using the Hello World! IBM MQ sample program as an example.
- Install the ILE C++ for IBM i compiler as directed in the Read Me first! manual that accompanies the product.
- Ensure that the QCXXN library is in your library list.
- Create the HELLO WORLD sample program:
- Create a module:
CRTCPPMOD MODULE(MYLIB/IMQWRLD) + SRCSTMF('/QIBM/ProdData/mqm/samp/imqwrld.cpp') + INCDIR('/QIBM/ProdData/mqm/inc') DFTCHAR(*SIGNED) + TERASPACE(*YES)
The source for the C++ sample programs can be found in /QIBM/ProdData/mqm/samp and the include files in /QIBM/ProdData/mqm/inc.Alternatively, the source can be found in library SRCFILE(QCPPSRC/LIB) SRCMBR(IMQWRLD).
- Bind this with IBM MQ-supplied service programs to
produce a program object:
CRTPGM PGM(MYLIB/IMQWRLD) MODULE(MYLIB/IMQWRLD) + BNDSRVPGM(QMQM/IMQB23I4 QMQM/IMQS23I4)
To build a threaded application use the re-entrant service programs:CRTPGM PGM(MYLIB/IMQWRLD) MODULE(MYLIB/IMQWRLD) + BNDSRVPGM(QMQM/IMQB23I4[_R] QMQM/IMQS23I4[_R])
- Execute the HELLO WORLD sample program, using SYSTEM.DEFAULT.LOCAL.QUEUE:
CALL PGM(MYLIB/IMQWRLD)
- Create a module:
Parent topic: Building IBM MQ C++ programs