Skip to main content

LNK2001: unresolved external symbol _ODBCRW32 using MQ Series

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

MQ Series and SQL calls in the same program produce this error:

Creating library DEBUG\\MQsqlACD.lib and object DEBUG\\MQsqlACD.exp

MQsqlACD.OBJ : error LNK2001: unresolved external symbol _ODBCRW32

DEBUG\\MQsqlACD.exe : fatal error LNK1120: 1 unresolved externals

Rebuild complete with errors

Resolution:

Normally MQSeries COBOL programs require the LITLINK directive, however when you use sql you cannot use this directive as it causes link errors.  You need to remove the litlink directive and use a procedure pointer to load the mqseries dll like follows:

Use the Procedure-Pointer method, which will permit the same program to be run on a machine running MQSeries Client, or the MQSeries Server.   This does not require the addition of MQMCB32.LIB or MQICCB32.LIB when creating EXE or DLL.

       IDENTIFICATION DIVISION.

       PROGRAM-ID. 'MQODBCPUT'

       environment division.

        WORKING-STORAGE SECTION.

===>    01  WORK-AREAS.

===>        05  LIBPTR               PROCEDURE-POINTER.

===>        05  BADPTR               PROCEDURE-POINTER.

       PROCEDURE DIVISION.

===>       SET LIBPTR TO ENTRY "MQMCB32".

===>         set BadPtr to entry "xyzzy"

===>         if LIBPTR = BadPtr

===>            SET LIBPTR TO ENTRY "mqiccb32".

           CALL    'MQCONN'

            USING QM-NAME, HCONN,

            COMPLETION-CODE, CON-REASON.

Old KB# 7098