Despite following various posts on using and linking to unmanaged C++ code from a C++/CLI wrapper dll, I cannot resolve these link issues.
1>MyClassAdapter.obj : error LNK2028: unresolved token (0A00000A) "public: __thiscall MyClass::~MyClass(void)" (??1MyClass@@$$FQAE@XZ) referenced in function "public: void * __thiscall MyClass::`scalar deleting destructor'(unsigned int)" (??_GMyClass@@$$FQAEPAXI@Z)
1>MyClassAdapter.obj : error LNK2028: unresolved token (0A00000B) "public: __thiscall MyClass::MyClass(void)" (??0MyClass@@$$FQAE@XZ) referenced in function "public: __clrcall WrapperLayer::MyClassAdaptor::MyClassAdaptor(void)" (??0MyClassAdaptor@WrapperLayer@@$$FQ$AAM@XZ)
1>MyClassAdapter.obj : error LNK2019: unresolved external symbol "public: __thiscall MyClass::MyClass(void)" (??0MyClass@@$$FQAE@XZ) referenced in function "public: __clrcall WrapperLayer::MyClassAdaptor::MyClassAdaptor(void)" (??0MyClassAdaptor@WrapperLayer@@$$FQ$AAM@XZ)
1>MyClassAdapter.obj : error LNK2019: unresolved external symbol "public: __thiscall MyClass::~MyClass(void)" (??1MyClass@@$$FQAE@XZ) referenced in function "public: void * __thiscall MyClass::`scalar deleting destructor'(unsigned int)" (??_GMyClass@@$$FQAEPAXI@Z)
I have a unmanaged native C++ dll with a simple class, exporting/importing symbols accordingly
// MyClass.h
#ifdef _EXPORTING
#define DLL_PUBLIC __declspec(dllexport)
#else
#define DLL_PUBLIC __declspec(dllimport)
#endif
class DLL_PUBLIC MyClass { . . . };
And I can see .dll and .lib linker file being generated after building.
Then I have the managed C++/CLI wrapper project (also a dll), which links to the MyClass.lib in the Linker->Input->Additional Dependencies setting. Also included the .h file from MyClass in the wrapper project, and I can see the sln can see MyClass.h file.
// MyClassAdaptor.h
#include "MyClass.h"
namespace WrapperLayer
{
public ref class MyClassAdaptor
{
. . .
private:
MyClass* _myclass;
};
}
What can possibly be missing?