Some DirectShow Samples Break in Visual Studio 2005【转载】

 
                                      

Microsoft Visual Studio 2005
版本 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
版本 2.0.50727 SP1

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

[Note: This post applies to the Platform SDK for Windows Server 2003 SP1 and Server 2003 R2. These issues were fixed in the Windows SDK for Vista.]  

Some of the DirectShow samples break if you install Visual Studio 2005 Beta 2. Most of the errors that I found fall into three categories:

  • C4430: Missing type specifier. To conform with C++, undeclared types do not default to int. All types must be declared. Fix: Declare the type, or suppress the warning with the "/wd4430" flag.baseclass的debug版本使用"/wd4430"方法,release版本在代码出错提示的地方声明相关变量,这在下面有具体的方法说明
  • C4996: ' xxxx' was declared deprecated. You may be including an older version of strsafe.h from the DirectX SDK or the Platform SDK. You should include the version installed with Visual Studio. (But it's probably harmless to ignore this warning.)
  • C2065: 'xxx': undeclared identifier. To conform with C++, the scope of a variable declared inside a "for" loop is restricted to the loop. Fixes: (a) Move the declaration outside the for loop. (b) Redeclare the variable in multiple scopes, if you don't need it to persist outside the loop. (c) Set the /Zc:forScope flag. (You can find this under Project, Properties, Configuration Properties, C/C++, Language, Force Conformance In For Loop Scope. Set to "No".)

Here are the specific fixes that I made. Warning: I have not thoroughly tested these, and I only tried them under the "Windows XP 32-bit Debug" environment in Platform SDK. You should use your own judgment before making any of these fixes.

  • BaseClasses\ctlutil.h (278)  
        (LONG) operator=(LONG);
  • BaseClasses\wxdebug.cpp (564)
        static DWORD g_dwLastRefresh = 0;
  • BaseClasses\winutil.cpp (2092)
       UINT Count;
       for (Count = 0;Count < Result;Count++) {
  • BaseClasses\outputq.cpp (635)
       long iDone = 0;
        for (iDone = 0;
  • Capture\AmCap\amcap.cpp (691)
       for(int i = 0; i < NUMELMS(gcap.rgpmAudioMenu); i++)
  • Capture\AmCap\amcap (2795)
        for(int i = 0; i < NUMELMS(gcap.rgpmAudioMenu); i++)
  • DMODemo\dsutil.cpp (686)
        DWORD i = 0;
        for( i=0; i<m_dwNumBuffers; i++ )
  • dmoimpl.h (622)   [In the Platform SDK headers]
        for (DWORD dw = 0; dw < NUMBEROFOUTPUTS; dw++) {
  • DMO\GargleDMO\MedParamBase\param.cpp (91)
        for (DWORD dwIndex = 0; dwIndex < cParams; dwIndex++)
  • DMO\GargleDMO\MedParamBase\param.cpp (309)
        CCurveItem *pCurve = NULL;
        for (pCurve = pCurveHead;
  • DMO\GargleDMO\gargle.cpp (145)
        for (DWORD i = 0; i < cOutputStreams && SUCCEEDED(hr); ++i)
  • Filters\Dump\dump.cpp (426)
        for (int Loop = 0;Loop < (DataLength % BYTES_PER_LINE);Loop++)
  • Filters\Gargle\gargle.cpp (212)
        static int m_nInstanceCount; // total instances
  • Filters\RGBFilters\RateSource\ratesource.cpp (382)
       for( int y = 0 ; y < DEFAULT_HEIGHT ; y++ )
  • Filters\RGBFilters\RateSource\ratesource.cpp (387)
       for( int y = 0 ; y < DEFAULT_WIDTH ; y++ )
  • VMR\VMRXclBasic and VMR\Ticker: LNK1181: cannot open input file 'dxguid.lib'. This was an error in the makefile. Change to read:
        DXLIB="$(DXSDK_DIR)\Lib\x86" (currently says "x32")
  • VMR\VMRXcl and VMR\VMRMulti: C1083: Cannot open include file: 'd3dxmath.h': No such file or directory. This is an old DX header that is no longer included in DX or in Visual Studio. Unfortunately the only fix is todownload an older version of the DirectX SDK.
  • VMR9\MultiVMR9\GamePlayer\character.cpp (383)
        DWORD i = 0;
        for (i = 0; i < pMeshContainer->NumInfl; ++i)
  • VMR9\MultiVMR9\DLL\MixerControl.h (28)
        static const DWORD MultiVMR9Mixer_DefaultFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;
  • VMR9\VMRAllocator: error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (etc).   Add this to the makefile:
        LINK32_LIBS = \
        comsuppw.lib \
        shell32.lib \

另外还有相关介绍:

http://hi.baidu.com/yrworld/blog/item/118eda80813dd1d39123d99f.html

DirectShow在vs2005中配置directshow开发环境
2008-03-24 14:05

先介绍系统环境:
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还是2005年1月,整整两年,今天又重操旧业。
这次在VS2005上使用DirectShow,首次编译发现出现以下错误:
error C2146: syntax error : missing ';' before identifier 'PVOID64'

看了很多关于这个问题的讨论,解答,无非就是改写winnt.h中的代码:
原代码:

typedef    void     * PVOID;   
typedef   
void     * POINTER_64    PVOID64;

在这两行代码前增加:

#define     POINTER_64    __ptr64

但这明显是下下之策,而且真正原因没人说的清楚。

看到一位xd,给了一种解释,是比较正确的, 如下:
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,从而导致出错。
方法1:
在Tools -> Options -> Projects and Solutions -> VC++ Directories -> Include Fles里确保系统包含目录(以S打头的)在最前面,同时在 project properties下面的“C/C++ -> General”中确保“Additional Include Directories”为空(因为它会被优先编译,这样就轮不到VC\PlatformSDK\Include\basetsd.h),所有的包含目录都应该在上面的include里面。这种方法不用改代码。
方法2:
在DXSDK自己的basetsd.h里自己定义#define POINTER_64 __ptr64
Trackback:http://hi.baidu.com/maxgoto/blog/item/fc40a86e8ec1f3da81cb4aff.html

PVOID64问题解决后,还要对VS2005进行配置:
先把dxsdk中提供的baseclass编译通过,用四种方式编译,会分别生成四个lib,一般只用到了其中的Debug和Release文件,
在tool|option|vc++ directories中包含的files中设置如下。
这里需要加入得include files有三种:
D:\SDK\DXSDK\Include
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses
D:\SDK\DXSDK\Samples\C++\Common\Include

在后边的library files中也需要增加三到四种的文件:
D:\SDK\DXSDK\Lib
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses\Release

把以上设置好,需注意调整include file的位置,一般让platformSDK\Include位于DXSDK\Include后面,
基本就可以将DirectShow程序在vs2005环境中编译通过。

DirectShow 在VS2005中环境配置
http://blog.cnii.com.cn/?uid-75821-action-viewspace-itemid-24418

一.DirectShow的环境配置:
本人使用的是VS2005,要使用DirectShow进行编程,需要对环境进行必要的配置。

第一步:对dssdk中的baseclass.sln进行编译,生成需要的debug和release文件,具体步骤如下:
在VS6中,安装DirectShow9c版本之后,直接打开BaseClass中的VS6工程baseclasses.dsw文件,直接编译即可,编译Debug Release Debug_Unicode   Release_Unicode四个版本,都需要进行额外的设置(头文件或者链接库目录设置)。
DirectShow的BaseClass中已经带了VS2005的工程文件baseclasses.sln,在vs2005中打开此文件,提示你进行必要的工程转换,转换之后开始编译,编译过程一般会出现下面两个问题:
(1)C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
(2)error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(3)error C2065: 'Count' : undeclared identifier
第一类问题的解决:安装xpsp2,如何将其include目录包含进去;一般将其放在dshow头文件之后,放在platsdk目录之前;
第二类问题的解决:错误发生在:operator=(LONG);函数定义中,这是因为在VC6中,如果没有显示的指定返回值类型,编译器将其视为默认整形;但是vs2005不支持默认整形,解决这个问题不能修改每个没有显示指示返回值类型的函数地方,可以用wd4430来解决;具体的在工程选项中的c++/Command Line中添加/wd4430即可。
第三个错误发生在for循环中,vs6中for循环中定义的变量相当于在for外面定义,可以在for之外地方使用;但是vs2005for循环中定义变量相当于域{}变量,只能在for循环中使用。要解决这个问题,可以通过修改vs2005的工程选项:”Project Option” --– “ C++ ” —-- “Language” --- “Force Comformance in For Loop Scrope” 设置为No即可。
完成上面的设置,BaseClass工程基本可以编译通过了。

第二步:需要设置相应的配置
在把dxsdk中提供的baseclass编译通过后,用四种方式编译,会分别生成四个lib,一般只用到了其中的Debug和Release文件,在tool|option|vc++ directories中包含的files中设置如下。
这里需要加入得include files有三种:
D:\SDK\DXSDK\Include
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses
D:\SDK\DXSDK\Samples\C++\Common\Include

在后边的library files中也需要增加三到四种的文件:
D:\SDK\DXSDK\Lib
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug
D:\SDK\DXSDK\Samples\C++\DirectShow\BaseClasses\Release

把以上设置好,基本就可以将DirectShow程序在vs2005环境中编译通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值