Gen 8.6 DB2 "LNK2019: unresolved ... _sprintf referenced in function _C4ERRMSG"
search cancel

Gen 8.6 DB2 "LNK2019: unresolved ... _sprintf referenced in function _C4ERRMSG"

book

Article ID: 191472

calendar_today

Updated On:

Products

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

Issue/Introduction

Windows 10 Enterprise
Visual Studio Professional 2015 with Update 3

Using Gen 8.6 sample model and Window Code Generation for DB2 UDB.
The load module GUIMENU fails to build and Review shows GUIMENU.OUT contains LNK2019 error:
=====
...
...Copying C:\Program Files (x86)\CA\Gen86\gen\.\STUBDB2N.OBJ to C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\OBJC\STUB.OBJ

=====================Load Module Script Environment=================
Operating System: WINDOWS
"Database Manager: DB2 UDB"
Environment:      WINDOWS
Language:         C
Codepage:         1252
Model:            GEN SAMPLE MODEL 8 6
Subset:           ALL
Level:            9.2.A6.01

==============================SUMMARY===============================
Summary of Load Module Script Results for Load Module GUIMENU:
==============================LEGEND================================
Legend: ... precedes information about an operation to be performed.
        --- precedes results from an operation which just completed.
        *** precedes error info from an operation which just failed.
        (Symbols preceding info are indented to convey step levels.)

==============================DETAILS===============================
Details of GUIMENU Load Module Script Results:

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.


...Compiling Stub resources
 copy "C:\Program Files (x86)\CA\Gen86\gen\version\applno.bat" "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\applno.bat"
        1 file(s) copied.
 call "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\applno.bat" YES "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\" GUIMENU "C:\Program Files (x86)\CA\Gen86\gen\" GUI
APPLNO.BAT : CA Gen BUILDTIME and BUILDVER update file
 rc -r -DWIN -D_AFXDLL -DIEF_BITMAP=. -I"%IEF_BITMAP%" -I"C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\." -I"C:\Program Files (x86)\CA\Gen86\gen\version" -DCUSTOMER_APPL -fo"C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\STUB.RES" "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\stub.rc"
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336

Copyright (C) Microsoft Corporation.  All rights reserved.


...Linking Load Module stub GUIMENU
 link /NOLOGO /SUBSYSTEM:WINDOWS -entry:WinMainCRTStartup -out:"C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\GUIMENU.EXE"  /DELAYLOAD:WRGN.DLL "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\OBJC\STUB.OBJ" "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\OBJC\STUBMAIN.OBJ" "C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\STUB.RES" @"C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\STUB.LNK"
STUB.OBJ : error LNK2019: unresolved external symbol _sprintf referenced in function _C4ERRMSG
C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\GUIMENU.EXE : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.
**************************** 
Link step for STUB.EXE using C:\Users\Administrator\Documents\CA\Gen 8.6\Models\sample.ief\c\STUB.LNK failed with errors. 
=====

The same problem occurs after Gen 8.6 Complete PTF WKS86200 is installed.
When building for ODBC/ADO.NET the error does not occur

Environment

Release : 8.6
Component : Gen Build Tool

Resolution

In Gen 8.6 GA file STUBDB2N.SQC did not contain the line:
#include <stdio.h>

That line was added to an updated STUBDB2N.SQC installed with PTF RTN86106/RO98577 which is also included in Gen 8.6 Complete PTF WKS86200/SO09618 which is the current baseline for a Gen 8.6 Windows installation:
The RTN86106 PTF description reports the problem as:
=====
SYMPTOMS:
Setting the build token OPT.BUILD_SRC to force a build of the STUBDB2N.SQC
when targetting Windows/DB2-UDB will result in a LINK error like the
following:


STUB.OBJ : error LNK2019: unresolved external symbol _sprintf
=====

TEST RESULTS
1. For version Gen 8.6 GA (before RTN86106 is installed) when using default value of BT Profile "C" Token OPT.BUILD_SRC=NO, the error "STUB.OBJ : error LNK2019: unresolved external symbol _sprintf referenced in function _C4ERRMSG" occurs. Also for that version with OPT.BUILD_SRC=YES the same error occurs (per PTF description)

2. After installing Gen 8.6 Complete PTF WKS86200, the problem still occurs when using default OPT.BUILD_SRC=NO.
However when using OPT.BUILD_SRC=YES the problem is resolved. OPT.BUILD_SRC=YES forces a precompile of STUBDB2N.SQC followed by compile to create a new STUBDB2N.OBJ which is copied to STUB.OBJ for the link process.