I made a custom interface on an ATL project and successfully inherited it on to a custom DirectShow filter. I can access the interface with the QueryInterface() function in a MFC .EXE application, but end up with a LNK2001 unresolved external symbol error when I tried to query the interface from a non-MFC DLL.
I have included INITGUID.h and VIVEoutput.h (from my custom ATL project). I have tried different placements of these header files. I have linked to the VIVEoutput.lib in the debug folder of my custom ATL project. I still end up with LNK2001! Could anyone tell me what else have I missed?
Thanks in advance
Michael
PS: I used Visual C++ 6 for the MFC .EXE and moved up to Visual C++ 2003 for the DLL. But I'm still using unmanaged code.
Thanks for the tip. Unfortunately, it did not work out.
I have made a simple win32 application to illustrate my problem (see below) and attached VIVEoutput.h. Project settings need to include strmiids.lib and Quartz.lib. Including VIVEoutput.lib was ineffectual.
It's frustrating because I have worked it successfully before and now, because I have forgotten something, it's now giving lnk2001 error and I can't figure out what the problem is.
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
/////////////////////////
// Declare variables
/////////////////////////
HRESULT hr;
CLSID filterClsid;
CLSIDFromString(L"{70E102B0-5556-11CE-97C0-00AA0055595A}", &filterClsid); // Video renderer
IBaseFilter* pFilter = 0;
IIPDVDec *pDvDec = 0;
IVIVEoutput1* pVIVEoutput = 0; // need VIVEoutput.h
int pNumber[1000];
/////////////////////////////////
// Initialise COM and filter
/////////////////////////////////
hr = CoInitialize(NULL);
hr = CoCreateInstance(filterClsid, 0, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, reinterpret_cast<void**>(&pFilter));
////////////////////
// Problem area
////////////////////
hr = pFilter->QueryInterface(IID_IIPDVDec,reinterpret_cast<void**>(&pDvDec)); // For comparison, doesn't actually do anything
hr = pFilter->QueryInterface(IID_IVIVEoutput1, (void **)&pVIVEoutput); // This is the problem line
if (pVIVEoutput != 0) // To avoid error when line above is commented out
pVIVEoutput->Output(pNumber);
//////////
// Exit
//////////
MessageBox(0,"OK","Try",0);
if (pDvDec != 0)
pDvDec->Release();
if (pFilter != 0)
pFilter->Release();
CoUninitialize();
return 0;
}
After compiling your directshow filter you should have a file named like "VIVEoutput_i.c" (or something like that) in directshow filter project directory...
Try to add that file into the project where you are using your filter...
VIVEoutput.h just declares IID_IVIVEoutput1 however doesn't define it...
Thanks Martin, it WORKED! You were right, it needed both the header and the implementation. The weird thing is: neither of those files were included in my original MFC EXE that has been cheerfully calling the custom interface. I can't find any unusual project settings either. Typical windows programming?
Anyway, many thanks. Your advice saved me I don't know how many hours of frustration.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.