473,480 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combine Managed and Unmanaged Code

Hi,

I have to write a managed C++ wrapper around an existing, unmanaged C++
class. First tests suggested it should work, but after adding the complete
unmanaged code, I get the following linker errors:

LINK : error LNK2020: unresolved token (0A00001A) _CxxThrowException
LINK : error LNK2020: unresolved token (0A00001C) exception.__ctor
LINK : error LNK2020: unresolved token (0A00001E) exception.__dtor
LINK : error LNK2020: unresolved token (0A000020) delete
LINK : fatal error LNK1120: 4 unresolved externals

It looks like it has something to do with the use of the STL in the
unmanaged part: As soon as I comment in such lines as

#include <vector>
#include <list>

....I get loads of unresolved externals. Is there a problem with using the
STL in managed C++? I tried the whole day now, but now I ran out of ideas.
Any help greatly appreciated!

Thanks in advance,
ulrich

P.S.: The project is a managed code library (dll).
Feb 23 '06 #1
3 1854
"Ulrich Sprick" <ul***********@gmx.de.xyz> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
I have to write a managed C++ wrapper around an existing, unmanaged C++
class. First tests suggested it should work, but after adding the complete
unmanaged code, I get the following linker errors:

LINK : error LNK2020: unresolved token (0A00001A) _CxxThrowException
LINK : error LNK2020: unresolved token (0A00001C) exception.__ctor
LINK : error LNK2020: unresolved token (0A00001E) exception.__dtor
LINK : error LNK2020: unresolved token (0A000020) delete
LINK : fatal error LNK1120: 4 unresolved externals

It looks like it has something to do with the use of the STL in the
unmanaged part: As soon as I comment in such lines as

#include <vector>
#include <list>

...I get loads of unresolved externals. Is there a problem with using the
STL in managed C++? I tried the whole day now, but now I ran out of ideas.
Any help greatly appreciated!

Thanks in advance,
ulrich

P.S.: The project is a managed code library (dll).


I can't say for certain that it is your problem, but I can tell you that
there are (obscure?) rules for building mixed-mode DLLs pre-VS2005. And if
you break those rules, you can get bizarre looking messages from the linker.

I suggest that you take a look at this link:

http://support.microsoft.com/?id=814472

to see if your DLL is doing anything that is prohibited.

BTW, that KB article has a link to an article detailing some of the gotchas
in mixed-mode development.

Regards,
Will
Feb 23 '06 #2
Wow - that was a REALLY fast response!!! Thanks a lot, I think I'll have a
sleepless night now...

Regards, ulrich
"William DePalo [MVP VC++]" <wi***********@mvps.org> schrieb im Newsbeitrag
news:OL*************@TK2MSFTNGP12.phx.gbl...
"Ulrich Sprick" <ul***********@gmx.de.xyz> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
I have to write a managed C++ wrapper around an existing, unmanaged C++
class. First tests suggested it should work, but after adding the
complete unmanaged code, I get the following linker errors:

LINK : error LNK2020: unresolved token (0A00001A) _CxxThrowException
LINK : error LNK2020: unresolved token (0A00001C) exception.__ctor
LINK : error LNK2020: unresolved token (0A00001E) exception.__dtor
LINK : error LNK2020: unresolved token (0A000020) delete
LINK : fatal error LNK1120: 4 unresolved externals

It looks like it has something to do with the use of the STL in the
unmanaged part: As soon as I comment in such lines as

#include <vector>
#include <list>

...I get loads of unresolved externals. Is there a problem with using the
STL in managed C++? I tried the whole day now, but now I ran out of
ideas. Any help greatly appreciated!

Thanks in advance,
ulrich

P.S.: The project is a managed code library (dll).


I can't say for certain that it is your problem, but I can tell you that
there are (obscure?) rules for building mixed-mode DLLs pre-VS2005. And if
you break those rules, you can get bizarre looking messages from the
linker.

I suggest that you take a look at this link:

http://support.microsoft.com/?id=814472

to see if your DLL is doing anything that is prohibited.

BTW, that KB article has a link to an article detailing some of the
gotchas in mixed-mode development.

Regards,
Will

Feb 23 '06 #3
"Ulrich Sprick" <ul***********@gmx.de.xyz> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
Wow - that was a REALLY fast response!!!
Well, _I_ have seen those errors here.
Thanks a lot,


You are welcome.

Regards.
Will
Feb 23 '06 #4

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

Similar topics

1
2098
by: Eric Twietmeyer | last post by:
Hello, I'm starting to investigate cs, managed c++ and interoperating with a very large unmanaged code base. We are going to use Windows Forms (written in cs) to replace our old fashioned GUI. ...
3
3472
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
12
1609
by: doug | last post by:
I understand the basics of what managed code offers and that you open yourself up to security issues if you allow unmanaged code. We already have a decent amount of VB6 code to include COM DLLs. ...
25
2976
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
0
7046
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7048
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7088
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
183
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.