Combine Managed and Unmanaged Code

U

Ulrich Sprick

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).
 
W

William DePalo [MVP VC++]

Ulrich Sprick said:
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
 
U

Ulrich Sprick

Wow - that was a REALLY fast response!!! Thanks a lot, I think I'll have a
sleepless night now...

Regards, ulrich
 

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