使用Visual Studio.net 2005 编译 Microsoft Platform SDK/Samples/Multimedia/DirectShow/BaseClasses 的时候,
使用nmake ,
总是会出现一些编译过去的怪问题,
如:
环境:winxp SP2, Visual studio 8.0.5..., with .net framework 2.0.50727, Microsoft DirectX SDK (August 2007), and Microsoft Platform SDK (5.2.3790.1830.15.PlatformSDK_Svr2003SP1_rtm )
c:/Programme/Microsoft Platform SDK/Samples/Multimedia/DirectShow/BaseClasses/ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
in ctlutil.h
private:
// Prevent bugs from constructing from LONG (which gets
// converted to double and then multiplied by 10000000
COARefTime(LONG);
operator=(LONG);
};
c:/Programme/Microsoft Platform SDK/Samples/Multimedia/DirectShow/BaseClasses/ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
<- the line 278 referes to " operator=(LONG);"
================================================
on ctlutil.h, but I get another error C4430 in wxdebug.cpp
./wxdebug.cpp(564) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
the line is: static g_dwLastRefresh = 0;
I have no ideia which type g_dwLastRefresh should be.
the code block is as follows:
BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level)
{
if(g_fAutoRefreshLevels)
{
// re-read the registry every second. We cannot use RegNotify() to
// notice registry changes because it's not available on win9x.
static g_dwLastRefresh = 0;
DWORD dwTime = timeGetTime();
if(dwTime - g_dwLastRefresh > 1000) {
g_dwLastRefresh = dwTime;
// there's a race condition: multiple threads could update the
// values. plus read and write not synchronized. no harm
// though.
DbgInitModuleSettings(false);
}
}
and on winutil.cpp
./winutil.cpp(2104) : error C2065: 'Count' : undeclared identifier
code block:
"
// And likewise compare against the last ten entries
Result = GetSystemPaletteEntries(hdc,PalHiStart,PalLoCount,SystemEntries);
for (Count = 0;Count < Result;Count++) {
========================================
改正方法:
I had to change the code provided with platform SDK.
First the ctlutil.h from "operator=(LONG); " to "COARefTime& operator=(LONG); "
This solves one error and brings out 10 more.
Then wxdebug.cpp
from "static g_dwLastRefresh = 0; " to "static int g_dwLastRefresh = 0; "
Compile again and change in winutil.cpp
"for (Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) { " to "for (int Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) { "
in outputq.cpp add the line
long iDone = 0; just before the "
for (iDone = 0;
iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway); "
appear to still be having problems with linking errors, i've managed to narrow it down to a few lines of code which cause the problem
Following the PushSource filter sample within the Platform SDK:
// directshow includes
#include <streams.h>
#include <initguid.h>
#include <Qedit.h> // for ISampleGrabber
#include <dvdmedia.h>
{8B578D13-87B2-488f-A4C1-AC8D065590D3}
DEFINE_GUID(CLSID_MyPushSource, 0x8b578d13, 0x87b2, 0x488f, 0xa4, 0xc1, 0xac, 0x8d, 0x6, 0x55, 0x90, 0xd3);
class MyPushSource : public CSource
{
public:
MyPushSource(IUnknown *pUnk, HRESULT *phr);
};
MyPushSource::MyPushSource(IUnknown *pUnk, HRESULT *phr)
: CSource(NAME("MyPushSource"), pUnk, CLSID_MyPushSource)
{
// do nothing yet
}
This code causes the following linking errors:
1>dracscrp.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CSource::FindPin(unsigned short const *,struct IPin * *)" (?FindPin@CSource@@UAGJPBGPAPAUIPin@@@Z )
1>dracscrp.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CBaseFilter::JoinFilterGraph(struct IFilterGraph *,unsigned short const *)" (?JoinFilterGraph@CBaseFilter@@UAGJPAUIFilterGraph@@PBG@Z )
1>dracscrp.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CBaseFilter::QueryVendorInfo(unsigned short * *)" (?QueryVendorInfo@CBaseFilter@@UAGJPAPAG@Z )
The libraries which are included in my solution are:
strmbase.lib strmiids.lib quartz.lib winmm.lib vfw32.lib odbc32.lib odbccp32.lib atls.lib comsupp.lib
I feel I must have missed something, or have the newest DirectX SDK, and Platform SDK not got anything about the CSource any more, its really confusing me.
=================解决方法=====================
Look out for "Treat wchar_t as Built in type" option on the C/C++ Language tab. If you've been using an older version of strmbas* built from the base classes, you could have said "No" to this option. Change it back to "Yes".
还有一些链接错误,可以如下改正:
打开c/c++ >> Language >> Treat wchar_t as Built-in Type 设为 Yes.
Runtime Library ---->> Multi-threaded Debug(/MTd)
摘自:http://www.cnblogs.com/sawayaka/