CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    12

    LNK2001 with QueryInterface(custom interface)

    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.

  2. #2
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147
    You probably need to include the .tlb (type library) file in the application that needs to use the ATL COM component.

    Copy it to your source folder then on the file tab, right click on the project, select add file... and then select it.

    Hope this helps,

    - Nigel

  3. #3
    Join Date
    Oct 2003
    Posts
    12
    Dear Nigel,

    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.

    Any help would be much appreciated.

    Thanks in advance,
    Michael

    // try.cpp: simple win32 .exe

    #include "INITGUID.h"
    #include "stdafx.h"
    #include "DShow.h"
    #include "VIVEoutput.h" // custom interface here

    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;
    }
    Attached Files Attached Files

  4. #4
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    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...

    martin

  5. #5
    Join Date
    Oct 2003
    Posts
    12
    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.

    Best regards,
    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured