第一步
最简单的错误。 这个错误类似于如下的error messsage:
1>cameraEmpty.obj : error LNK2001: unresolved external symbol IID_IVideoWindow
1>cameraEmpty.obj : error LNK2001: unresolved external symbol PIN_CATEGORY_PREVIEW
1>cameraEmpty.obj : error LNK2001: unresolved external symbol MEDIATYPE_Video
1>cameraEmpty.obj : error LNK2001: unresolved external symbol CLSID_VideoCapture
1>cameraEmpty.obj : error LNK2001: unresolved external symbol CLSID_FilterGraph
1>cameraEmpty.obj : error LNK2001: unresolved external symbol CLSID_CaptureGraphBuilder
这种样式的错误的原因就是你没有把那些directx常用的那些lib引入。解决方案就是在stdafx.h里面加入这段代码:
view plaincopy to clipboardprint?
#pragma comment(lib, "atlosapis.lib")
#pragma comment(lib, "strmbase.lib")
#pragma comment(lib, "Strmiids.lib")
#pragma comment(lib, "dmoguids.lib")
#pragma comment(lib, "atlosapis.lib")
#pragma comment(lib, "strmbase.lib")
#pragma comment(lib, "Strmiids.lib")
#pragma comment(lib, "dmoguids.lib")
第二步
很多时候把这些库引入了还是有其他的连接错误, 形如:
1>cameraEmpty.obj : error LNK2019: unresolved external symbol "public: __cdecl CTransInPlaceFilter::CTransInPlaceFilter(wchar_t *,struct IUnknown *,struct _GUID const &,long *)" (??0CTransInPlaceFilter@@QAA@PA_WPAUIUnknown@@ABU_GUID@@PAJ@Z) referenced in function "public: __cdecl CRotateFilter::CRotateFilter(wchar_t *,struct IUnknown *,long *)" (??0CRotateFilter@@QAA@PA_WPAUIUnknown@@PAJ@Z)
1>cameraEmpty.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CTransformFilter::FindPin(wchar_t const *,struct IPin * *)" (?FindPin@CTransformFilter@@UAAJPB_WPAPAUIPin@@@Z)
1>cameraEmpty.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CBaseFilter::JoinFilterGraph(struct IFilterGraph *,wchar_t const *)" (?JoinFilterGraph@CBaseFilter@@UAAJPAUIFilterGraph@@PB_W@Z)
1>cameraEmpty.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CBaseFilter::QueryVendorInfo(wchar_t * *)" (?QueryVendorInfo@CBaseFilter@@UAAJPAPA_W@Z)
这样的链接错误来源于工程里面的一个设定:
Configuration Properties=>C/C++=>Language
把Treat wchar_t as Built-in Type的值设成 NO! 这样这一类的问题大致解决了。 很多时候到这一步就可以编译了,当然我指的是Release build已经可以通过编译了,但是在debug版本编译的时候还有一个问题存在,这就是第三步。
第三步。
cameraEmpty.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __cdecl CBaseFilter::NonDelegatingRelease(void)" (?NonDelegatingRelease@CBaseFilter@@UAAKXZ)
这个是很经典的问题,原因在于随SDK发布的这个strmbase的lib在debug模式下是错误的,要一个新的strmbase.lib和strmbase.pdb的包来替代。
具体步骤如下: 2、将PB目录下C:/WINCE500/PUBLIC/DIRECTX/SDK/SAMPLE/DSHOW/BASECLASSES下的CPP文件拷贝到创建工程的文件夹下,打开BASECLASSES文件夹下的HEADER/source文件(文本文件方式),按照source文件中的文件列表,将指定的CPP文件加入到工程中; 3、修改文件wxutil.cpp文件
编译出来后,将产生的lib文件copy到应用程序工程目录下,编译,发现还是有链接错误 1>cameraEmpty.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CBaseFilter::QueryVendorInfo(wchar_t * *)" (?QueryVendorInfo@CBaseFilter@@UAAJPAPA_W@Z)等 根据之前第二步处理方式判断,将lib工程的 Configuration Properties=>C/C++=>Language 把Treat wchar_t as Built-in Type的值设成 NO! 这样问题才最终解决了。 |