LNK2020 DLL using another DLL

  • Thread starter Thread starter rob
  • Start date Start date
R

rob

I did create a dll A using managed c++. I have no problem using this
dll in a .NET application using c#. I now have another dll B that uses
functionality from the first dll A. When building dll B I get the
following link error:

error LNK2020: unresolved token (060000ff) ....

I then added the project for dll A as a reference (in addition to
System, System.Data, System.Xml) to dll B. But now I get the following
error:

error C2011: 'MyNamespace::MyClass' : 'class' type redefinition

liba.h(60) : error C2011: 'MyNamespace::MyClass' : 'class' type
redefinition liba.dll : see declaration of 'MyNamespace::MyClass'

I do not think liba.h is included twice in project B because I used
pragma once PLUS #ifdefs. Actually, it seems that there is a definition
of my class in liba.h and another one in liba.dll.

In any case, what is the proper way to use functionality from one
managed C++ dll in another managed C++ dll?

Thanks,
Rob
 
Hi rob!
I did create a dll A using managed c++.
...
I then added the project for dll A as a reference (in addition to
System, System.Data, System.Xml) to dll B. But now I get the following
error:

error C2011: 'MyNamespace::MyClass' : 'class' type redefinition

liba.h(60) : error C2011: 'MyNamespace::MyClass' : 'class' type
redefinition liba.dll : see declaration of 'MyNamespace::MyClass'

Please do *not* include _any_ h-file from DLL-A!
In the managed world everything is included by the DLL! All
classes/members are retrieved via reflection, so there is no need to
include h-files.

Just add the the DLL-A to the referencec in you rB-project. Then you can
use it...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
Jochen,

Thanks for the reply. Actually, what you suggested is what I tried
first. The problem is that if I do not include the header file but just
a reference to the dll then building the project already breaks at the
compile stage because it doesn't know stuff that is in the header file.

So please let me verify that what you say also applies to managed C++
and not just C#. Also could the problem be that I am using /clr instead
of /clr:safe or /clr:pure?

Maybe as a final note I should mention that the main code is written in
C that has C++ code wrapped around it. Now I am trying to add support
for managed C++.

Rob
 
rob said:
Jochen,

Thanks for the reply. Actually, what you suggested is what I tried
first. The problem is that if I do not include the header file but just
a reference to the dll then building the project already breaks at the
compile stage because it doesn't know stuff that is in the header file.

So please let me verify that what you say also applies to managed C++
and not just C#. Also could the problem be that I am using /clr instead
of /clr:safe or /clr:pure?

Maybe as a final note I should mention that the main code is written in
C that has C++ code wrapped around it. Now I am trying to add support
for managed C++.

Rob

You have to add an #using <yourReferenced.dll> directive in you source
file...

Willy.
 
Back
Top