VS2019 linker fails to detect the object file of static library with CFG enabled

Vinay Kumar L 21 Reputation points
2022-04-08T09:44:38.33+00:00

We have a static library xyz.lib. It has abc.obj in it.
These object files are built with CFG flag enabled.

But creation of DLL from this static library fails with lot unresolved symbols.

LINK /nologo /NODEFAULTLIB /OPT:NOREF /NXCOMPAT /DynamicBase /STACK:2097152 /def:"xyz.def" /out:xyz.dll pqr.obj /implib:"xyz.lib" /dll xyz.lib

The same works fine. If I recreate/rearrange the xyz.lib with some dummy operations on static library(xyz.lib) as follows:

LIB xyz.lib /EXTRACT:abc.obj /OUT:abc.obj
LIB /out:xyz.lib xyz.lib abc.obj

Any specific reason for this behavior? Any workaround to resolve this problem?

NOTE: This behavior is not seen with Visual Studio 2015

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,514 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,482 questions
Visual Studio Setup
Visual Studio Setup
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
952 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,519 questions
{count} votes