Unable to resolve LNK2001 error despite method appearing in lib file and being included

75 Views Asked by At

I have a C++ project GWRegistry that is set up as x64 DynamicLibrary Win32Proj. It is attempting to call a public constant in another DLL that has been added as a native nuget package. The project that created the dll was also set up as x64 DynamicLibrary Win32Proj.

The call is to AuthorizationManagerDbo::m_strGUIDString (yeah...the naming convention of m_str prefix is horrible...old code...not my fault).

The linker is returning error

unresolved external symbol "public: static class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class
ATL::ChTraitsCRT<wchar_t> > > const AuthorizationManagerDbo::m_strGUIDString"
(?m_strGUIDString@AuthorizationManagerDbo@@2V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@B)

I have confirmed that the dll containing the constant is being linked in as seen in the following snippet

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe
... /LIBPATH:C:\dev\WS\Gateway\packages\DbProcsEngine.1.2.3\build\native\x64 ... 
DbProcsEngine.lib ...
/MANIFEST ... /MACHINE:X64 /DLL x64\Debug\GWRegistry.res

I have also confirmed that the constant exists in the DbProcsEngine.lib via dumpbin.exe as seen here

Version      : 0
Machine      : 8664 (x64)
TimeDateStamp: D2185CEF
SizeOfData   : 00000086
DLL name     : DbProcsEngine.dll
Symbol name  : ?m_strGUIDString@AuthorizationManagerDbo@@2V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@B (public: static class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const AuthorizationManagerDbo::m_strGUIDString)
  Type         : data
  Name type    : name
  Hint         : 458
  Name         : ?m_strGUIDString@AuthorizationManagerDbo@@2V?$CStringT@_WV?$StrTraitATL@_WV?$ChTraitsCRT@_W@ATL@@@ATL@@@ATL@@B

And that the signatures, ATL::ChTraits.., CString, etc. match.

Here is the declaration of the variable in the cpp file

public:

    // typedef CAtlString CLVString;   (elsewhere in code)
    static const CLVString m_strGUIDString;

I did read one SO post that mentioned a mismatch between CharacterSet could cause an issue but have confirmed that both are Unicode.

I am out of ideas of where else to look.

0

There are 0 best solutions below