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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 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