MS Visual Studio 2008. This seems to be a name mangling issue, but I can't find the right search terms to come up with an answer.
I have a dynamic lib that has a class in it, which is using a logging class from a static logging library. The dynamic lib imports the static library in the project settings. I use this static lib in other projects, so I know it compiles and links without error.
Sample code:
Dynamic.h:
extern "C"
{
__declspec(dllexport) BYTE GetData();
};
Dynamic.cpp:
#include "MyClass.h"
static MyClass g_Inst;
BYTE GetData() { return g_Inst.GetData(); }
MyClass.h:
#include "Logging.h"
class MyClass
{
public:
BYTE GetData() { CLogging::Instance().AddString("Test"); }
};
Linker:
error LNK2019: unresolved external symbol "public: void __cdecl CLogging::AddString(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsOS<wchar_t> > > const &)" (?AddString@CLogging@@QAAXABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsOS@_W@ATL@@@@@ATL@@@Z) referenced in function "public: unsigned char __cdecl MyClass::GetData(void)" (?GetData@MyClass@@QAAEXZ)
Edit: thinking maybe it was a Unicode or MFC issue, I checked on the project settings for the Dynamic project:
The Logging project:
And two other projects that also pull in Logging with no problems:
The only difference I can see is the one that doesn't work is built as a dynamic dll.