Re: Compiling LibGraph in VC7.1

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Sheldon


I am a DirectShow newbie and I have just converted
DirectShow sample code and your library to VC 7.1.
I thought that the following may be useful to others:

Glad that someone finds my code useful.

Compiling LibGraph and TESTAPPLICATION under VC7.1:
The Link errors LNK2006 and LNK4006 that
occured when compiling LibGraph.dll were fixed by
adding Libcmt.lib (and Libcmtd.lib in the debug build)
to the [Linker][Input][Ignore Specific Library] option.
See: http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652

This LIBCMT LIBCPMT MSVCRT MSVCPRT shenanigan is faced by 10000s of
programmers who start using Visual Studio and its become a black art to
get a clean link.

1) Your program requires the C runtime library
2) Your program requires the CPP runtime
3) Your Baseclasses library is linked with both of these

now the issue is there are both static and dynamic versions of the
runtime libs in both debug and release versions in both multithread and
single thread versions ( lets not bring in ANSI/Unicode just yet or MFC
or ATL in static or dynamic forms )

Ignore single threaded libraries... and we have

Static - LIBCMT.LIB and LIBCMTD.LIB , LIBCPMT.LIB and LIBCPMTD.LIB
Dynamic - MSVCRT.LIB and MSVCRTD.LIB , MSVCPRT.LIB and MSVCPRTD.LIB ,
which make your exe link to MSVCRT.DLL and MSVCP71.DLL ro MSVCRTD.DLL
and MSVCP71D.DLL ( FWIW its not legal to distribute the debug runtime
DLLs with your program )

Now if your baseclasses is linked statically to the CRT ( as it is by
default in the existing project files ) and LibGraph uses dynamic CRT
you're having duplicate symbols....

Building a project using Libgraph with the wrong CRT linkage will cause
it to complain , but I've not found a way of making it detect a
static-CRT linked baseclasses.lib

The solution is ===NOT=== to simply put in "/NODEFAULTLIB" but rather
to recompile Baseclasses.lib with MSVCRT/MSVCPRT linkage ( by setting
the Project Options->C++ -> Code generation to "Multithread Debug DLL"
or "Multithread DLL" for the debug and release libs respectively.

/NODEFAULTLIB:LIBCPMT is a quick way to fix link errors, but its an
ugly hack!
Not cool at all!

I'm thinking it may be possible to write a program that can rip apart a
..LIB file and replace a static CRT with a DLL linkage and recreate the
lib. Someday ill get round to that.

Also:
Errors LNK2005 and C4995, that mentioned wsprintfW
and such like, i.e. found when compiling the DirectShow
sample code CompressView, were fixed by selecting
Use Unicode Character set in [General][Character set].

Thanks for that, I'm firmly rooted in the early 90s so yet have to
compile a build with Unicode, guess ill have to drag myself into the
next decade.
I've a feeling that those errors come with the Platform SDK based
DirectX SDK.
Sometimes the best SDKs are the older ones :D
I'm still using the old DX9 sdk from oct 2004 and the Platform SDK from
2003

Thanks for your library and input, I am endeavouring to
build a filter to remove instrumental noise from digital
copies of old VHS video, and getting there slowly.

Queries, suggestions and criticism welcome anytime!

BTW

A COM wrapper for LibGraph has been developed !
Use Libgraph from Delphi, VB, and .NET languages...

( thanks to wilywit for letting me distribute it ( it was made for his
project ) , Ill get round to posting that code sometime after Jan 15th
( I'm getting married in a weeks time ) )

Thanks and regards
Vivek

.


Quantcast