Platform SDK Build Environment Link Errors (Standard C++ Library)

DirectShow COM Stream Filter DLL's fail to link with #include headers from the Standard C++ Library.  To illustrate this, a very simple example found here:

http://msdn.microsoft.com/library/default.asp url=/library/en-us/vccore/html/vcwlkCreatingACOMServerUsingNotepad.asp

will exhibit the problems.  If you follow the steps to create and build this simple COM DLL from the Platform SDK command shell build environment used for DirectShow examples (WindowsXP-32 Bit - Debug) the example will fail to link with unresolved symbols from the Standard C++ <iostream> library.

However, if you follow the example and build from the VisualStudio.Net 2003 provided command shell build environment it will build, link and run exactly as described.

Unfortunately, many of the Platform SDK examples will not build under the alternative VisualStudio.Net 2003 provided command shell build environment making the two build environments mutually exclusive and incompatible.

If anyone knows what fundemental differences there are between the two build environments provided by Microsoft VisualStudio.NET 2003 and the Platform SDK that can be altered to get the above example to link under the Platform SDK build environment, your help would be greatly appreciated.



Answer this question

Platform SDK Build Environment Link Errors (Standard C++ Library)

  • Alexandre SAC

    I have resolved this problem:

    The Platform SDK makefile needs a few changes for the C++ Standard Library

    • Modify MSVCRT = msvcrt.lib msvcprt.lib  (msvcrtd.lib msvcprtd.lib for debug)

    • Remove /D_DLL_CPPLIB /Dtry=__try /Dexcept=__except /Dleave=__leave /Dfinally=__finally

    • Add /EHsc to get the correct exception handling model after removing the try/catch redefinitions

    That will do the trick.  I thought msvcrt.lib and msvcprt.lib were mutually exclusive but you actually need both of them for C++ standard library usage.  As for the redefinitions of try/catch in the makefile, you will get syntax errors in the string libraries from <iostream> if you use the Microsoft extensions.  Apparently this Microsoft trick/hack allows C code to have the C++ feel and behavior of exception handling but causes great havoc when using the C++ standard libraries - better to use the real thing as defined by the C++ language.

    Note: These modifications are for VS 2003 builds of the PlatformSDK samples.  However, if you use VS 2005 you will get more problems when it comes time to register your DLL with regsvr32.exe.  This is because of the manifest files for MSVCR80.dll.  See posts on MANIFEST and MSVCR80.DLL to resolve these issues when you upgrade to VS 2005.


  • Erland Sommarskog

    How do you build the sample with nmake

  • Steven He

    I tried
    • Modify MSVCRT = msvcrt.lib&nbsp;msvcprt.lib&nbsp; (msvcrtd.lib&nbsp;msvcprtd.lib for debug)
    • Remove /D_DLL_CPPLIB /Dtry=__try /Dexcept=__except /Dleave=__leave /Dfinally=__finally
    • Add /EHsc to get the correct exception handling model after removing the try/catch redefinitions

    then the "string" error came back.

    C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\assert.h(47) : error C2059: syntax error : 'string'

    It seems I either get the error for "string". Or an error for 'catch'

    C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\ostream(592) : error C2059: syntax error : 'catch'

    How can we get ride of both :)

  • Platform SDK Build Environment Link Errors (Standard C++ Library)