尽管有关使用和链接来自C ++ / CLI包装器DLL的非托管C ++代码的各种帖子,但我无法解决这些链接问题。
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)
我有一个带有简单类的非托管本机C ++ dll,相应地导出/导入符号
// MyClass.h
#ifdef _EXPORTING
#define DLL_PUBLIC __declspec(dllexport)
#else
#define DLL_PUBLIC __declspec(dllimport)
#endif
class DLL_PUBLIC MyClass { . . . };
我可以看到构建后生成.dll和.lib链接器文件。
然后我有托管的C ++ / CLI包装器项目(也是一个dll),它链接到Linker-> Input-> Additional Dependencies设置中的MyClass.lib。还包含了包装器项目中MyClass的.h文件,我可以看到sln可以看到MyClass.h文件。
// MyClassAdaptor.h
#include "MyClass.h"
namespace WrapperLayer
{
public ref class MyClassAdaptor
{
. . .
private:
MyClass* _myclass;
};
}
可能会遗漏什么?
答案 0 :(得分:1)
几点: