BullseyeCoverage
When building with Microsoft C++ and coverage build enabled, you
get error LNK2001
or LNK2019
on a function symbol F which is
defined in a DLL but not exported from the DLL by name.
The error does not occur with coverage build disabled.
Your compile settings do not include any optimization option which
expands inline functions.
error LNK2001: unresolved external symbol "F" error LNK2019: unresolved external symbol "F" referenced in function "G"
There is an inline function G that calls F. With coverage build disabled, G is not expanded inline and so G is defined inside the DLL. With coverage build enabled, G is expanded inline and so G is defined outside the DLL. Function G might be a compiler-generated default constructor or destructor.
You can confirm this as the cause by reproducing the error with Coverage Build disabled and inline function expansion enabled.
Use either of the resolutions below.
__declspec(dllexport)
To enable inline function expansion with
Visual Studio,
select your project, choose menu command Project Properties
,
navigate to C/C++ Optimization
,
and set Inline Function Expansion
to
Any Suitable (/Ob2)
.
Updated: 10 Sep 2018
Copyright © Bullseye Testing Technology. All Rights Reserved.