简体   繁体   English

未解析的外部符号…QueryInterface

[英]unresolved external symbol …QueryInterface

I have an unmanaged C++ class which has a com map inside of it. 我有一个非托管的C ++类,其中包含一个com映射。 EX: EX:

BEGIN_COM_MAP
(MyClass)
  COM_INTERFACE_ENTRY(...)
END_COM_MAP

But now from within the class if I try calling this->QueryInterface I get the following error: 但是现在从类中,如果我尝试调用this-> QueryInterface,则会出现以下错误:

unresolved external symbol "public: virtual long __stdcall CTest::QueryInterface(struct _GUID const &,void * *)" (?QueryInterface@CTest@@UAGJABU_GUID@@PAPAX@Z) referenced in function "public: __thiscall CTest::CTest(void)" (??0CTest@@QAE@XZ)

But now, if I try and implement a QueryInterface method I get the following error: 但是现在,如果我尝试实现QueryInterface方法,则会出现以下错误:

error C2535: 'HRESULT CTest::QueryInterface(const IID &,void **) throw()' : member function already defined or declared

What am I doing wrong? 我究竟做错了什么?

Thanks for the answers, but the issue in the end seems to of been that I was trying to QueryInterface from the constructor. 感谢您的回答,但最终的问题似乎是我试图从构造函数中查询QueryInterface。 Once I moved it to a separate method everything worked fine. 一旦将其移至单独的方法,一切都可以正常工作。

Does anyone have any docs on why you cannot call QueryInterface from a constructor? 有谁对您为什么不能从构造函数调用QueryInterface有任何文档?

The problem is you are not linking properly to the ATL lib files. 问题是您没有正确链接到ATL lib文件。 Check your project options in Visual Studio and make sure you are statically linking to ATL. 在Visual Studio中检查项目选项,并确保您静态链接到ATL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM