DirectShow常见问题_登船常见问题的处理
DirectShow常见问题由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“登船常见问题的处理”。
一、配置方法
1、先编译SamplesC++DirectShowBaseClaes中的工程文件。注意工程的默认选项是D ebug_Unicode的,在非Unicode的工程中使用还需要编译Debug版本的。
“DXSDK90SAMPLESC++DIRECTSHOWBASECLASSESbaseclaes.dsw的release版本”,指的是运行DXSDK90SAMPLESC++DIRECTSHOWBASECLASSESbaseclaes.dsw前,先在VC中选择Build->Set Active Configuration,再在对话框中选择BaseClaes-Win32 Release??
2、需要设置好VC中目录的设置
include的目录中添加 C:DXSDKSamplesC++DirectShowBaseClaes
Lib的目录中添加 C:DXSDKSamplesC++DirectShowBaseClaesDebug3、使用DirectShow时应该先执行
CoInitialize(NULL);
初始化COM,结束前
CoUninitialize();
关闭COM4、使用DirectShow的工程需要添加下面两个头文件
#include //DS接口、基类的定义
#include //CComPtr模板的定义
同时需要调整编译的选项
#pragma comment(lib,“strmbasd.lib”)
#pragma comment(lib,“winmm.lib”)
#pragma comment(linker,“/NODEFAULTLIB:libcmtd.lib”)
注意,VC自带的库中也有strmbasd.lib文件。一定要保证连接到DS的库中,否则会出现 strmbasd.lib(dllsetup.obj): error LNK2001: unresolved external symbol “cla CFactoryTemplate * g_Templates”(?g_Templates@@3PAVCFactoryTemplate@@A)
strmbasd.lib(dllentry.obj): error LNK2001: unresolved external symbol “cla CFactoryTemplate * g_Templates”(?g_Templates@@3PAVCFactoryTemplate@@A)
strmbasd.lib(dllsetup.obj): error LNK2001: unresolved external symbol “int g_cTemplates”(?g_cTemplates@@3HA)
strmbasd.lib(dllentry.obj): error LNK2001: unresolved external symbol “int g_cTemplates”(?g_cTemplates@@3HA)
之类的错误。
二.编译后出现的错误:
1、syntax error : identifier 'DWORD_PTR'
如果你安装了Miscrosof Platform SDK, 你也许会看到:
Compiling...e:directx9samplesc++directshowbaseclaeswxutil.h(53): error C2061: syntax error : identifier 'DWORD_PTR'
e:directx9samplesc++directshowbaseclaesctlutil.h(43): error C2504: 'IBasicVideo2' : base cla undefined
e:directx9samplesc++directshowbaseclaesctlutil.h(904): error C2146: syntax error : miing ';' before identifier 'm_dwAdvise' e:directx9samplesc++directshowbaseclaesctlutil.h(90): error C2501: 'DWORD_PTR' : miing storage-cla or type specifierse如果发生这种情况,你应该从“Tools”目录中选择“Option”,然后在include directory中将Platform SDK加到
VC inlcude之前:
2、LINK : fatal error LNK1104: cannot open file “mfc42ud.lib” mfc42ud.lib是专门给unicode用的build-->set active Configuration--> XXX win32 debug 这样就可以了
3、“CComPtr
CComPtr m_spApi;在控制台程序中可以编译成功,但mfc中报错,怎么回事?在线等待一下是错误信息:
error C2143: syntax error : miing ';' before '
error C2501: 'CComPtr' : miing storage-cla or type specifiers error C2059: syntax error : '
error C2238: unexpected token(s)preceding ';'
原因:缺少文件,在vc6中是atlbase.h,可能在.net中是atlcomcli.h 解决方法:在stdafx.h中加入#include
4、'ISampleGrabber' : undeclared identifier
加入代码#include
“C:DXSDKSamplesC++DirectShowCommondshowutil.cpp并且需要在project->settings-> link 中object/libary modules 中填加
C:DXSDKSamplesC++DirectShowBaseClaesdebugstrmbasd.lib winmm.lib ,同时要保证stdafx.h中 有#include #include #include
5、调用CoInitializeEx(),编译后显示未定义
CoInitializeEx()是利用COM组件时每个线程都要调用的函数,使用这个函数需要有如下设置:在Project-> setting-> C/C++标签下的Preproceor definitions中加入”_WIN32_WINNT=0x400"语句