DirectShow AMCap改装, 无法解析的外部符号 "class CFactoryTemplate * g_Templates"
错误 1 error LNK2001: 无法解析的外部符号 "class CFactoryTemplate * g_Templates" (?g_Templates@@3PAVCFactoryTemplate@@A)
错误 2 error LNK2001: 无法解析的外部符号 "int g_cTemplates" (?g_cTemplates@@3HA)
1>strmbase.lib(dllentry.obj) : error LNK2001: 无法解析的外部符号 "class CFactoryTemplate * g_Templates" (?g_Templates@@3PAVCFactoryTemplate@@A)
1>strmbase.lib(dllentry.obj) : error LNK2001: 无法解析的外部符号 "int g_cTemplates" (?g_cTemplates@@3HA)
把AMCap代码文件复制到MFC工程里面,出现上述两个错误:STRMBASE.lib已经链接,不知道问题出在哪。
dllentry.cpp里面与上面相关的代码是:
extern CFactoryTemplate g_Templates[1];
extern int g_cTemplates;
//called by COM to get the class factory object for a given class
STDAPI
DllGetClassObject(
REFCLSID rClsID,
REFIID riid,
void **pv)
{
if (!(riid == IID_IUnknown) && !(riid == IID_IClassFactory)) {
return E_NOINTERFACE;
}
// traverse the array of templates looking for one with this
// class id
for (int i = 0; i < g_cTemplates; i++) {
const CFactoryTemplate * pT = &g_Templates[i];
if (pT->IsClassID(rClsID)) {
// found a template - make a class factory based on this
// template
*pv = (LPVOID) (LPUNKNOWN) new CClassFactory(pT);
if (*pv == NULL) {
return E_OUTOFMEMORY;
}
((LPUNKNOWN)*pv)->AddRef();
return NOERROR;
}
}
return CLASS_E_CLASSNOTAVAILABLE;
}
//
// Call any initialization routines
//
void
DllInitClasses(BOOL bLoading)
{
int i;
// traverse the array of templates calling the init routine
// if they have one
for (i = 0; i < g_cTemplates; i++) {
const CFactoryTemplate * pT = &g_Templates[i];
if (pT->m_lpfnInit != NULL) {
(*pT->m_lpfnInit)(bLoading, pT->m_ClsID);
}
}
}