2
votes

I have an unmanaged C++ class which has a com map inside of it. 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:

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:

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

What am I doing wrong?

2

2 Answers

1
votes

Thanks for the answers, but the issue in the end seems to of been that I was trying to QueryInterface from the constructor. 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?

0
votes

The problem is you are not linking properly to the ATL lib files. Check your project options in Visual Studio and make sure you are statically linking to ATL.