Gen Windows/DB2 build unresolved symbols & LNK4272 ('x64'/'X86' conflict)
search cancel

Gen Windows/DB2 build unresolved symbols & LNK4272 ('x64'/'X86' conflict)

book

Article ID: 244903

calendar_today

Updated On:

Products

Gen - Workstation Toolset Gen - Host Encyclopedia Gen - Run Time Distributed Gen

Issue/Introduction

Trying to generate/build Gen Windows GUI application on Windows 10 using IBM DB2 v10.5 but it failed per below. Is IBM DB2 v10.5 supported for generation?

CASCADE.out file shows:
===
...
...Precompiling sql in E0005020
 CD "D:\models\model1.ief\c\."
 TIDB2PRP.EXE /INAME=E0005020.SQC /DB=TESTDB/USER=Administrator /PASSWORD=xxxxxxxxxx

LINE    MESSAGES FOR E0005020.SQC
------  --------------------------------------------------------------------
        SQL0060W  The "C" precompiler is in progress.
        SQL0091W  Precompilation or binding was ended with "0" 
                  errors and "0" warnings.


LINE    MESSAGES FOR E0005020.BND
------  ----------------------------------------------         ----------------------
        SQL0061W  The binder is in progress.
        SQL0091N  Binding was ended with "0" errors and "0" warnings.

...Compiling E0005020
 cl -c -W3 -Od -nologo -D_X86_ -Dtry=__try -Dexcept=__except -Dleave=__leave -Dfinally=__finally -D_CRT_SECURE_NO_DEPRECATE -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -DWIN32 -DMSC -DWINNT -D_MT -D_DLL -DNONTTRACE -DWIN_NT -DREENTRANT -Fo"D:\models\model1.ief\c\OBJC\E0005020.OBJ" "D:\models\model1.ief\c\E0005020.C"
E0005020.C
...

Compiles for CASCADE DLL Dependencies done.
...Linking CASCADE DLL
 link /OPT:NOREF  /NOLOGO /NODEFAULTLIB:LIBCMT /DLL /SUBSYSTEM:WINDOWS  /entry:_DllMainCRTStartup@12 /OUT:"D:\models\model1.ief\c\CASCADE.DLL"  /implib:"D:\models\model1.ief\c\CASCADE.LIB" /def:"D:\models\model1.ief\c\CASCADE.DEF" @"D:\models\model1.ief\c\CASCADE.LNK"
   Creating library D:\models\model1.ief\c\CASCADE.LIB and object D:\models\model1.ief\c\CASCADE.exp
F5050773.OBJ : error LNK2001: unresolved external symbol _sqlaaloc@16
...
F5050773.OBJ : error LNK2001: unresolved external symbol _sqlacall@20
...
F5050773.OBJ : error LNK2019: unresolved external symbol _sqlasetdata@24 referenced in function _f_118489174_test2
F5051557.OBJ : error LNK2001: unresolved external symbol _sqlasetdata@24
...
F5050773.OBJ : error LNK2019: unresolved external symbol _sqlastop@4 referenced in function _f_118489174_test2
F5051557.OBJ : error LNK2001: unresolved external symbol _sqlastop@4
...
F5050773.OBJ : error LNK2019: unresolved external symbol _sqlastrt@12 referenced in function _f_118489174_test2
F5051557.OBJ : error LNK2001: unresolved external symbol _sqlastrt@12
...
C:\PROGRA~1\IBM\SQLLIB\LIB\DB2API.LIB : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
D:\models\model1.ief\c\CASCADE.DLL : fatal error LNK1120: 5 unresolved externals
===

Environment

Release : 8.6

Component : Gen Build Tool

Resolution

For Gen 8.6 only DB2 11.x ESE (and subsequent minor versions) is officially supported for Windows code generation. That is per the Gen 8.6 Technical Requirements > Third-Party Software Version section of the documentation.

However the DB2 version does not appear to be the root cause of the reported error with RI Triggers build i.e. the CASCADE.OUT warning LNK4272 indicates that the problem relates to a bitness mismatch of the DB2 library being referenced and that of the Gen application being built, so the DB2 _sql* symbols referenced in the Gen generated code are not being resolved.
A Gen Windows GUI client application can only be 32-bit and the CASCADE.OUT shows it is using library DB2API.LIB from DB2PATH of "C:\PROGRA~1\IBM\SQLLIB" which is the 64-bit directory "C:\Program Files\IBM\SQLLIB". This is causing a conflict with the 32-bit Gen GUI application build.

Support installed DB2 10.5.0.1 (Win_x86-64) and observed that as well as the 64-bit libraries in C:\PROGRA~1\IBM\SQLLIB\LIB the install also has 32-bit libraries in this directory C:\PROGRA~1\IBM\SQLLIB\LIB\Win32.
Testing the Gen 8.6 sample application using the Windows Packaged GUI application with DB2 selected, the same link errors/warning occur when the BT profile DBMS>DB2 token LOC.DBLIB="C:\PROGRA~1\IBM\SQLLIB\LIB" i.e.
===
   Creating library C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sampdb2.ief\c\CASCADE.LIB and object C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sampdb2.ief\c\CASCADE.exp
E3407893.OBJ : error LNK2019: unresolved external symbol _sqlaaloc@16 referenced in function _f_118489153_fk
F7484035.OBJ : error LNK2001: unresolved external symbol _sqlaaloc@16
...
E3407893.OBJ : error LNK2019: unresolved external symbol _sqlacall@20 referenced in function _f_118489153_fk
F7484035.OBJ : error LNK2001: unresolved external symbol _sqlacall@20
...
E3407893.OBJ : error LNK2019: unresolved external symbol _sqlasetdata@24 referenced in function _f_118489153_fk
F7484035.OBJ : error LNK2001: unresolved external symbol _sqlasetdata@24
...
E3407893.OBJ : error LNK2019: unresolved external symbol _sqlastop@4 referenced in function _f_118489153_fk
F7484035.OBJ : error LNK2001: unresolved external symbol _sqlastop@4
...
E3407893.OBJ : error LNK2019: unresolved external symbol _sqlastrt@12 referenced in function _f_118489153_fk
F7484035.OBJ : error LNK2001: unresolved external symbol _sqlastrt@12
...
C:\PROGRA~1\IBM\SQLLIB\LIB\DB2API.LIB : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sampdb2.ief\c\CASCADE.DLL : fatal error LNK1120: 5 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\link.EXE"' : return code '0x460'
===

If change token LOC.DBLIB to use the 32-bit library i.e. LOC.DBLIB="C:\PROGRA~1\IBM\SQLLIB\LIB\Win32", then the link and build is successful.

Additional Information

Related article for Gen GUI load module build error with DB2: Gen 8.6 DB2 "LNK2019: unresolved ... _sprintf referenced in function _C4ERRMSG"