Windows Mobile 上常见的 DirectShow 链接错误

来源:互联网 发布:安德鲁拜纳姆 知乎 编辑:程序博客网 时间:2024/05/16 08:19

最近在Mobile上搞Camera的时候碰到了千奇百怪的链接错误,在这里记录一下。

第一步

最简单的错误。 这个错误类似于如下的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的包来替代。对于PPC SDK,这个位置在

C:/Program Files/Windows CE Tools/wce500/Windows Mobile 5.0 Pocket PC SDK/Lib/ARMV4I

下面,这个跟新的包的位置在http://www.alexfeinman.com/files/strmbase.zip可以下载到。

当然如果你不用这个包取代也可以, 你可以编译release版, release版总是work的, 更或者, 你自己去实现一个基类的NonDelegatingRelease方法也可以

这个东西还是挺折腾的,希望其他人不要被烦到 哈哈

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hhygcy/archive/2009/05/14/4183834.aspx