0

I have a number of DLLs building and linking against my application without issues, but this static lib is giving me troubles.

Present in it is just one class. The class is declared with __declspec(dllexport) when building the lib and __declspec(dllimport) when including the class's header in the application.

When I attempt to build the application with an instance of MyClass, I get:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall MyClass::~MyClass(void)"
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MyClass::MyClass(void)"

And if I attempt to build the application with a pointer to MyClass, I get the same unresolved externals plus two additional warnings:

warning LNK4217: locally defined symbol ??0MyClass@@QAE@XZ (public: __thiscall MyClass::MyClass(void)) imported in function _main
warning LNK4217: locally defined symbol ??1MyClass@@UAE@XZ (public virtual __thiscall MyClass::~MyClass(void))

Searching the web for LNK4217 suggests incorrect usage of the /M[TD]d? cl.exe switch. I recreated the Visual Studio solution and dragged over the sources to make sure it was provisioned correctly. For reference, both the Lib and app have /MDd.

4

0 回答 0