Menu

how to compile WebSphere MQ ".c" code ?

Compiling
2013-12-24
2013-12-24
  • Sebastia Altemir

    I am trying to use IBM WebSphere MQ "c" code (sample follows).

    The header file "cmqc.h" is located in c:\mq\tools\c\include",
    and the "librariy" file correponding to "cmqc.h" header is "mqm.lib" (server) or "mqic32.lib" (client),
    located at "c:\mq\tools\lib" and also "c:\mq\tools\lib64"

    Can someone provide me the syntax for compiling from command line ?

    The CMD file I have until now is

    ===
    c:\"Program Files (x86)"\Dev-Cpp\MinGW64\bin\gcc prova.c
    -I"c:\mq\tools\c\include"
    -L"c:\mq\tools\Lib\mqm.lib"
    -o prova.exe

    Thanks. Sebastian.

    pd.- my code :

    ===
    // fix for MinGW

    ifndef _int64

    define _int64 long long

    endif

    include < stdio.h >

    include < stdlib.h >

    include < string.h >

    include < cmqc.h >

    MQCHAR QMName [49] = "" ; / default QMgr name /

    int main ( int argc, char ** argv )
    {
    printf ( ">>> MQCONN(). QMN [%s].\n", QMgrName ) ;

    MQCONN ( QMgrName, / queue manager /
    & Hcon, / connection handle /
    & CompCode, / completion code /
    & CReason ) ; / reason code /

    }

    Error : MQM.LIB is not found (or not correct format ...)

    C:\Users\IBM_AD~1\AppData\Local\Temp\ccWKJ3ia.o:amqsecha.c:(.text+0x381): undefined reference to `MQCONN'

     

    Last edit: Sebastia Altemir 2013-12-24
    • Sebastia Altemir

      The complete error is this one :

      ===
      C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x381): undefined reference to MQCONN' C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x454): undefined reference toMQOPEN'
      C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x547): undefined reference to MQGET' C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x731): undefined reference toMQPUT1'
      C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x7a0): undefined reference to MQCLOSE' C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o:amqsecha.c:(.text+0x7f7): undefined reference toMQDISC'
      c:/program files (x86)/dev-cpp/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe
      : C:\Users\IBM_AD~1\AppData\Local\Temp\ccSNPvIr.o: bad reloc address 0x0 in section `.data'
      c:/program files (x86)/dev-cpp/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe
      : final link failed: Invalid operation
      collect2.exe: error: ld returned 1 exit status
      ===

      I have read that MQM.LIB is not completely "standard" ...

      It compiles OK with Microsoft "CL" compiler,
      ... but using Borland BCC32 I have this error :

      Error: 'C:\MQ\Tools\Lib\MQM.LIB' contains invalid OMF record, type 0x21 (possibly COFF)

      Any clue ?

       
  • Sebastia Altemir

    I'd say I fixed it, by using this compilation command :

    ===
    c:\"Program Files (x86)"\Dev-Cpp\MinGW64\bin\gcc amqsecha.c -I"c:\mq\tools\c\include" -L"c:\mq\tools\Lib64" -o AMQSECHA.EXE -lmqm
    ===

    Sebastian, running few tests.

     
  • Sebastia Altemir

    Compilation ends OK, but MQCONN() fails with no explanation.
    So, "gcc" is not compatible with "mqm.lib" ?
    What is that COFF stuff ?
    Sebastian.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.