【发布时间】:2014-09-05 12:11:31
【问题描述】:
我正在尝试以下情况
我的 A.dll 正在加载 B.dll 并使用 A.dll 中存在的类对象的指针作为加载函数的参数调用它的函数
使用该对象引用我可以从 B.dll 调用 A.dll 的函数吗??
我的B.dll函数如下,
bool LogManagerThread::StartLogThread(void* AObj)
{
A* pobj;
pobj = (A*)AObj;
pobj->PrintTestMsg();
return true;
}
'A'是A.dll中的类
如果我这样调用,我会收到链接错误为“未解析的外部符号”.. 其中 PrintTestMsg() 是 A.dll 的“A 类”中的方法
Error 11 error LNK2001: unresolved external symbol "public: void __thiscall A::PrintTestMsg(void)" (?PrintTestMsg@A@@QAEXXZ) D:\ilrewrite2\ConsoleApplication1\LogManager.obj LogManager
【问题讨论】:
-
你为什么使用
void *?这也不是“参考”而是一个指针。但我也认为您可能需要向我们展示准确且完整的错误消息。 -
错误 11 错误 LNK2001: 无法解析的外部符号 "public: void __thiscall A::PrintTestMsg(void)" (?PrintTestMsg@A@@QAEXXZ) D:\write2\ConsoleApplication1\LogManager.obj LogManager
-
我的困惑是 A.dll 中的方法是否可以像我所做的那样在 B.dll 中调用? (通过从 A.dll 传递对象指针)
-
您应该链接到为
A.dll生成的.lib文件并从那里使用那些东西(而不是void*)。
标签: c++ dll void-pointers dllexport