您的位置:首页 > 其它

在vs2005中配置directshow开发环境

2012-12-15 03:04 375 查看
先介绍系统环境:

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

==================================================================================================

如果是2005应该没问题,在做DirectShow开发时经常会遇到版本配置的问题。

warning C4996: '_vsnprintf': This function or variable may be unsafe. ......

warning C4996: strcpy was declared deprecated

出现这样的警告,是因为VC2005之后的版本中认为CRT中的一组函数如果使用不当,可能会产生诸如内存泄露、缓冲区溢出、非法访问等安全问题。这些函数如:strcpy、strcat等。

对于这些问题,VC2005建议使用这些函数的更高级的安全版本,即在这些函数名后面加了一个_s的函数。这些安全版本函数使用起来更有效,也便于识别,如:strcpy_s,calloc_s等。

当然,如果执意使用老版本、非安全版本函数,可以使用_CRT_SECURE_NO_DEPRECATE标记来忽略这些警告问题。办法是在编译选项 C/C++ | Preprocessor | Preprocessor Definitions中,增加_CRT_SECURE_NO_DEPRECATE标记即可。

另外一种解决方法:

#pragma warning(disable:4996) //全部关掉

#pragma warning(once:4996) //仅显示一个

==================================================================================================

1>.\wxdebug.cpp(11) : warning C4603: “_WINDLL”: 未定义宏或在预编译头使用后定义发生改变

我把“_WINDLL”注释了

2>.\wxdebug.cpp(534) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

修改为:int nReturnValue = _vsntprintf_s( szBreakPointMessage, MAX_CHARS_IN_BREAK_POINT_MESSAGE, szFormatString, va );

3>.\wxdebug.cpp(777) : warning C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

修改:vsprintf_s(szInfo,lstrlen(szInfo), pFormat, va);

4>.\wxdebug.cpp(1167) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

修改为:_stprintf_s(m_String, TEXT("%.16g"), d);

不知道这样修改对不对,反正是没有警告了,请高手告知,谢谢
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: