[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


C++ .NET DLL base class problem ???

Posted on 2004-09-06
Medium Priority
Last Modified: 2008-01-09
Hi guys ...

I'm using visual C++ .net 2003 and am having linker problems when building the following managed class library (DLL) project :

using namespace System;
namespace Common
   public __gc class Base

   public __gc class Derived : public Base

It compiles successfully, but I get the following linker error :
TestFile error LNK2001: unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)(void *),void *)" (?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

The problem can be solved by commenting out the base destructor. However this is not a real solution ... as the base destructor will have some necessity in my project.

Anybody have any ideas why this happens ... and any possible workarounds would be much appreciated ?

Other postings of the same question include :

Question by:steve_hsk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 19

Accepted Solution

drichards earned 750 total points
ID: 11992763
Here's a solution someone posted:

>>I have also encountered this problem. In order to compile
>> succesfully you have to link msvcrt.lib with ur class lib.

I did not have any issues compiling and linking a class library with your code.  I checked and I already was linking with msvcrtd.lib (it was a debug build) for other reasons.  I removed msvcrtd.lib from my settings and got your problem along with the others which originally caused me to link with msvcrt.
LVL 19

Expert Comment

ID: 11992795
Just in case you need instructions:  go to the project properties Linker Input page and add msvcrtd.lib in debug configuration "Additional Dependencies".  Add msvcrt.lib to release configuration settings.  Make sure this matches the C\C++ Code Generation "Runtime Library" setting.   msvcrt(d) goes with "Multi-threaded Debug Dll (/MDd)".  If you choose other settings, I believe you will have to change the lib.  Here's a link to the docs for the runtime library compiler switch:


Author Comment

ID: 11995875
Thanks for this solution ... it works as stated :-)

If you could fill me in on 2 things I'd greatly appreciate it :-
(1) I'm curious as to why msvcrt.lib wasn't included as part of my project settings by default, and what this library is used for (MS VC++ Run time or MS v? Common Run Time ? What do MS say about this lib ?
(2) Which search engine and website did you find the solution ?

Many thanks,
LVL 19

Expert Comment

ID: 11996960
(1) I can't say for sure since I haven't found it documented anywhere, but I would guess it's because the runtime is not needed with a pure managed project and so it is not included by default.  Only when you use runtime functions (printf, etc.) do you need the runtime.    It appears that adding a destructor introduces unmanaged code and you need the runtime to handle the destructor code.  You do not need the derived class to have the problem with the destructor.  I tried removing "Derived" from the project and still it had linker errors without msvcrt.

(2) I used Google and searched for 'CxxCallUnwindDtor'.  Here's the ultimate link with the solution - Google found an index page for the message group that had this link.


Author Comment

ID: 11997498
Good enough :-)

Many thanks !

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question