DirectShow学习之一在vs2005中配置directshow开发环境

2011年12月04日 分类:学习笔记C++

先介绍系统环境:

  • XP Professional sp2
  • visual studio 2005 version 8.0.50727.42
  • DirectX 9.0(9.0b) SDK Update - (Summer 2003)

首先,就是编译baseclasses,什么是baseclasses?打开你的dx的sdk安装目录,例如: D:/DX90SDK/Samples/C++/DirectShow/ 这里就有一个叫baseclasses的工程,为安全起见,请先备份此工程。

1,双击baseclasses.sln打开,提示我们需要转换工程,按提示转换就是了,编译 提示错误:

1>D:/Microsoft Visual Studio 8/VC/PlatformSDK/include/winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
1>D:/Microsoft Visual Studio 8/VC/PlatformSDK/include/winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:/Microsoft Visual Studio 8/VC/PlatformSDK/include/winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'
1>D:/Microsoft Visual Studio 8/VC/PlatformSDK/include/winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:/Microsoft Visual Studio 8/VC/PlatformSDK/include/winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:/DX90SDK/Samples/C++/DirectShow/BaseClasses/ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

2,在Tools->Options->Projects and solutions->vc++ directories->show directories for里选择include files 然后增加

D:/DX90SDK/Include
D:/DX90SDK/Samples/C++/DirectShow/BaseClasses
D:/DX90SDK/Samples/C++/Common

可能会问题依旧,调整一下include files的顺序吧,把他们都放在最后,例如我的环境:

$(VCInstallDir)include
$(VCInstallDir)atlmfc/include
$(VCInstallDir)PlatformSDK/include
$(FrameworkSDKDir)include
D:/DX90SDK/Include
D:/DX90SDK/Samples/C++/DirectShow/BaseClasses
D:/DX90SDK/Samples/C++/Common

然后在project->BaseClasses properties->configuration->C/C++ -> General->Additional Include Directories里面的内容(.,../../../../include)删掉,重新编译,PVOID64的错误消失,原因如下:

POINTER_64 是一个宏,在64位编译下起作用,它包含在SDK目录下的BASETSD.H中(Microsoft Visual Studio 8/VC/PlatformSDK/Include/basetsd.h(23):#define POINTER_64 __ptr64),但DXSDK自己也带了一个basetsd.h,里面没有定义POINTER_64,从而导致出错,只需要改变include files的优先级即可。当然,也可以改写winnt.h中的代码,在下面这两行:

typedef void *PVOID;
typedef void *POINTER_64 PVOID64;

之前增加一行:

#define POINTER_64 __ptr64

3,到目前为止,还剩下:

BaseClasses/ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

这个错误,解决方法如下:

打开project->BaseClasses properties->configuration->C/C++ ->Command Line,增加/wd4430选项。 4, 接着编译,提示error C2065: ‘Count’ : undeclared identifier等等错误,这个是微软的历史遗留问题了,C++标准语法的问题,因为在之前在for循环内定义的变量可以在for之外的地方使用,即 在第一个for里for(int i,…),以后的for再使用i不必再声明,解决方法也很简单,打开project->BaseClasses properties->configuration->C/C++->Language->Force Comformance in For Loop Scrope设置为No即可。当然,也可以手动改代码,增加一个声明就是了。

经过上面几个步骤,应该是可以顺利编译了,对于其它版本的工程,照样设置就可以了,总共编译出下面4个文件备用:

BaseClasses/Debug/strmbasd.lib
BaseClasses/Debug_Unicode/strmbasd.lib
BaseClasses/Release/STRMBASE.lib
BaseClasses/Release_UnicodeSTRMBASE.lib

你或许需要在Tools->Options->Projects and solutions->vc++ directories->show directories for->library files里把它们加进去。

赶快编译DX90SDK/Samples/C++/DirectShow/Players/PlayDMO工程试试看吧。

以上资料整理自下面3个blog,一并列出:

DirectShow在VS2005中PVOID64问题和配置问题

http://www.cnblogs.com/RunOnTheWay/archive/2008/01/17/1043705.html

DirectShow 在VS2005中环境配置

http://blog.cnii.com.cn/?uid-75821-action-viewspace-itemid-24418

Some DirectShow Samples Break in Visual Studio 2005

http://blogs.msdn.com/mikewasson/archive/2005/05/23/some-directshow-samples-break-in-visual-studio-2005.aspx

作者:wuyuan 本文来自Wuyuan's Blog 转载请注明,谢谢! 文章地址: https://wuyuans.com/2011/12/directshow-vs2005-settings

近期文章

微信公众平台

分类目录

友情链接