How to Compile and Link MQ Programs on Linux

Someone on StackOverflow asked “How to compile a C program without knowing the include files”.

JasonE gave a really good answer, so I thought I would repeat it here:

  • To compile and link 64-bit MQ applications on Linux, follow the instructions here
  • To compile and link 32-bit MQ applications on Linux, follow the instructions here
  • In summary:

  • -I is for the product includes, which are (For Linux) usually in /opt/mqm/inc
  • -L is the path to the libraries in your example which are (For Linux) usually in /opt/mqm/lib (for 32 bit applications) and /opt/mqm/lib64 (for 64 bit applications)
  • -l (lower case L) is for the required library/libraries
  • and the actual library you need is either:

  • mqm – server bound C applications (ie -lmqm, which links with libmqm.so)
  • mqic – client bound C applications (ie -lmqic, which links with libmqic.so)
  • and a suffix of _r if you are building as a threaded application (ie you are linking with -lpthread as well, ie providing -lmqm_r or -lmqic_r which in effect links with libmqm_r.so or libmqic.so)

    cmqc.h is the name of the main header file, and there are other cmq*.h headers you can optionally include as well.

    Regards,
    Roger Lacroix
    Capitalware Inc.

    This entry was posted in C, C++, IBM MQ, Linux, Programming.

    Comments are closed.