Differences between CLI command line and CLI control lib project!?

A

Achim Domma

Hi,

I try to implement a control library in CLI/C++ which uses DirectShow. I
have these lines in my code, which should make it possible to use
DirectShow:

#include <initguid.h>
#include <dshow.h>
#pragma comment (lib, "strmiids.lib")
#pragma comment (lib, "Quartz.lib")
#pragma comment (lib, "ole32.lib")

In a command line CLI project, I can compile the "How to Play a File"
example from this url:

http://windowssdk.msdn.microsoft.com/en-us/library/ms783787.aspx

If I use the same code in my CLI control library project, I get the
following error:

error LNK2001: unresolved external symbol IID_IGraphBuilder

Any hint what might be the difference?

regards,
Achim
 
B

Bruno van Dooren [MVP VC++]

I try to implement a control library in CLI/C++ which uses DirectShow. I
have these lines in my code, which should make it possible to use
DirectShow:

#include <initguid.h>
#include <dshow.h>
#pragma comment (lib, "strmiids.lib")
#pragma comment (lib, "Quartz.lib")
#pragma comment (lib, "ole32.lib")

In a command line CLI project, I can compile the "How to Play a File"
example from this url:

http://windowssdk.msdn.microsoft.com/en-us/library/ms783787.aspx

If I use the same code in my CLI control library project, I get the
following error:

error LNK2001: unresolved external symbol IID_IGraphBuilder

Did you perhaps accidentally forget to include the appropriate header that
defines that IID?
Another likely cause of that problem is explained here:
http://vcfaq.mvps.org/com/13.htm

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
A

Achim Domma

Bruno said:
Did you perhaps accidentally forget to include the appropriate header that
defines that IID?
Another likely cause of that problem is explained here:
http://vcfaq.mvps.org/com/13.htm

I solved the problem: The library is per default compiled with /clr:pure
and the default for the executable ist /clr. If I compile the library
with /clr too, it work's fine so far.

Could somebody explain this behavior?

Achim
 
B

Ben Voigt

Achim Domma said:
I solved the problem: The library is per default compiled with /clr:pure
and the default for the executable ist /clr. If I compile the library with
/clr too, it work's fine so far.

Could somebody explain this behavior?

I suppose you are also using this interface directly from your executable.
When a native type is compiled in managed code, the assembly name becomes
part of the type's identity, so IID_IGraphBuilder in the assembly is
incompatible and can't satisfy a reference for IID_IGraphBuilder in the main
exe. When you compile in mixed mode, UUID becomes a native type, the normal
C++ rules apply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top