Harshdeep 2.0

May 30, 2006

DirectShow with Visual Studio 8

Filed under: Uncategorized — harshdeep @ 12:24 pm

Recently I had to upgrade some DirectShow code to VS8. This code was working fine as long as we were using VS7 but started crashing as soon as we switched to VS8.

I’m not really a DirectShow guru – this is the first time I had to dig a little bit in DirectShow code. A little googling and searching on forums indicated that a lot of people have faced problems in moving their DirectShow code to VS8. So, I’m listing my experiences here – it just might help someone save his time.

The first step was to get the latest DirectShow SDK – as I mentioned in the last post, it’s a part of the Platform SDK and Direct X SDK is required to build the samples. The first sample, Baseclasses, is what I needed. I built the static libraries strmbasd.lib (debug) and strmbase.lib (release) through nmake, as DirectShow documentation suggested, and linked them to the corresponding builds of my dll that uses DirectShow. This opened up a Pandora’s box of compiler, linker and run-time errors.

tchar.h was throwing a compiler error – “error C1189: Need to include strsafe.h after tchar.h”. Lots of people have complained about this error in the forums. dshow.h includes strsafe.h, so in this case the error simply reads “include tchar.h before including dshow.h”.

I was getting some “undefined symbols” link errors for functions that I could clearly see in Baseclasses code. It was because I’d used nmake to build the libraries. The default settings that it used were not compatible with the project settings of my DirectShow code.

I created a VS8 project for Baseclasses. All I had to do to fix the link errors was to match the “Character Set” and “Treat wchar_t as a Built-in type” settings in the project properties of Baseclasses and my dll that links to it. But this code was still crashing. Reason – different “Structure alignment” in the two projects. Using the same value in both the projects fixed it.

Moral of the story: Don’t use nmake to build Baseclasses for you – write a VS project and use the right settings.


1 Comment »

  1. Hi bro.

    Nice article i know it’ll help ppl.

    Though i’m one of those gits who so don’t know their way around VS that they’re not able to build anything with VS 😛

    Comment by nishant — June 6, 2006 @ 7:11 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: