473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

LNK2020 DLL using another DLL

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

Nov 17 '05 #1
6 1439
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/
Nov 17 '05 #2
rob
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

Nov 17 '05 #3
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/
Nov 17 '05 #4

"rob" <rm*******@yahoo.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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.
Nov 17 '05 #5
rob
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

Nov 17 '05 #6

"rob" <rm*******@yahoo.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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.
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token...
2
by: Jacob Cohen | last post by:
Under VC7.1, I am trying to wrap a native-C++ DLL that contains C++ objects in a Managed-C++ class library for use in a C# project. I created and compiled the native DLL under VC7.1 as a Win32...
1
by: Tony Baker | last post by:
Hi, If I 1) create a brand new Visual C++ Project -> Class Library (.Net) 2) in the stdafx.h file add #include <atlbase.h> I get the following errors: ------ Build started: Project: testATL,...
3
by: Simon Jefferies | last post by:
Hello, I am trying to use a Managed C++ .NET (DLL) Class library within my Managed C++ .NET forms application. I have both projects in the same solution and have the class library under my...
2
by: Vickie | last post by:
I have a very simple program with some computations. After using NODEFAULTLIB to get rid of LNK2005 errors such as: LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in...
0
by: Gustavo L. Fabro | last post by:
Greetings! I found myself with a LNK2020 linking problem using VS.NET 2003 under a situation that I was able to replicate in a small project. I found one workaround for the problem too, but...
0
by: crafuse | last post by:
Hello all, I'm trying to create a mixed DLL using VC++ .NET 2003. Specifically, I have some TAO CORBA .cpp files that I wish to include as native object code in the DLL and some managed classes...
0
by: Roland | last post by:
Hi, ultimately I want to call some unmanaged C++ class that contains some DirectShow code of mine from my C# classes, but for the time being I'd be happy if I could get this to build! I have...
2
by: tllee | last post by:
I wrote a simple stack program using class template on VC++ 2003 but am unable to resolve the following link errors: LINK : error LNK2020: unresolved token (0A000046) Stack.__dtor LINK : error...
3
by: S Wheeler | last post by:
Hi - I have a vc++ WinForms app. Can I override the WndProc so I can send custom messages to my app. Is there any way to do this? I need to notify the main form of events from a library. How is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.