0

I think I´ve read about everything concerning this error here at stackoverflow, but I cannot solve my problem: I have the DirectShow PushSource Filter sample project (.dll) which I managed to build in VS2013 and also a test project in another sln which is using some methods from the PushSource.dll. I linked the lib and everything but cannot get rid of this Linker error:

FilterGraphTestApp.obj : error LNK2019: unresolved external symbol "public: static class CUnknown * __stdcall CPushSourceBitmapSet::CreateInstance(struct IUnknown *,long *)" (?CreateInstance@CPushSourceBitmapSet@@SGPAVCUnknown@@PAUIUnknown@@PAJ@Z) referenced in function _main

code calling the CreateInstance member:

// Get the interface for DirectShow's GraphBuilder
IUnknown *pUnk = NULL;
HRESULT *pHr = NULL;
CBaseFilter *pPSBS = (CBaseFilter*)CPushSourceBitmapSet::CreateInstance(pUnk, pHr); 

pGB->AddFilter(pPSBS, L"ImagesToVideoFilter");
pGB->QueryInterface(IID_IMediaControl, (void **)&pMC);

pMC->Run();

Code of the calling funtion:

CUnknown * WINAPI CPushSourceBitmapSet::CreateInstance(IUnknown *pUnk, HRESULT *phr)
{
  CPushSourceBitmapSet *pNewFilter = new CPushSourceBitmapSet(pUnk, phr );
  if (phr)
  {
    if (pNewFilter == NULL) 
      *phr = E_OUTOFMEMORY;
    else
      *phr = S_OK;
  }

  return pNewFilter;
}

Any hints what else I could try?

Ilya
  • 4,583
  • 4
  • 26
  • 51
Richard
  • 27
  • 6

2 Answers2

2

Sample project produced you a DLL. You are not supposed to link it or associated LIB with your test application (FilterGraphTestApp). Trying to resolve quoted LNK2019 will get you nowhere.

Instead you are supposed to register the DLL so that it populates itself into list of registered DirectShow filters. Then you instantiate it from there interactively using GraphEdit, or programmatically using CoCreateInstance API and respective CLSID (alternatively you can use moniker).

You can bypass COM registration too and include PushSource header file to share some declarations, for for starters this could be left alone. To use CPushSourceBitmapSet::CreateInstance you won't need the DLL, LIB of the sample project. Neither you need the sample project, except that you would borrow source code from there into your own application and link files from BaseClasses directory (or LIB resulting from their build) to get the implementation right into your application without a DLL. This way CreateInstance would work.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
1

these can be good reasons :

  1. CreateInstance is decalred in header but not defined in cpp
  2. You are using CreateInstance but class which contains this is not exported in dll. i mean

    class __declspec(dllexport) YourClass { .... }

    you can check it by opening dll using notepad and search for 'CreateInstance', if it is not found then it is not exported to dll.

Jai
  • 1,292
  • 4
  • 21
  • 41
  • FYI - dumpbin gives a "nicer" output than notepad and it comes with Visual Studio :) – OMGtechy Apr 13 '16 at 10:54
  • after exporting the class I run into other problems: – Richard Apr 13 '16 at 11:18
  • Firstly I get this warning:warning C4275: non dll-interface class 'CSource' used as base for dll-interface class 'CPushSourceBitmapSet' and secondly my app can build now, but when running I get this error: A dependent dll was not found – Richard Apr 13 '16 at 11:20
  • then you are using wrong method, which is suppose to hide for external use. Try to find alternative of CreateInstance. or you have to export base class as well which can breach your design. – Jai Apr 13 '16 at 11:23
  • or you can create a class and export it.In one of its method call CreateInstance method. – Jai Apr 13 '16 at 11:25