// 所有原创文章转载请注明作者及链接
// blackboycpp(AT)gmail.com
// QQ群: 135202158
首先,就是编译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工程试试看吧。
=============================================
// 以下由blackboy修改于 2009-11-08:
按照以上的步骤配置后, 我的VC++ 2005编译DirectShow项目依然有问题, 提示IID_XXX之类的无法链接,
后来在“链接器->输入->附加依赖项”中添加了strmiids.lib, 问题解决。