error LNK2001: unresolved external symbol "void __cdecl __CxxCallUnwindDtor...

  • Thread starter Bruce Schechter
  • Start date
B

Bruce Schechter

I am experimenting with managed code in C++. But shortly into my
exploration, I've run into a Linker error which I cannot diagnose. (I have
searched MS knowledgebase, MSDN newsgroups, and Google, with no luck.)



Seems that the error somehow involves my usage of a destructor (like
~DualButton() and/or ~ToggleButton() below) in a derived class. But I am
not certain of that theory.



Can anyone point out my error or give me a link to appropriate help? Error
and relevant code is included below.



Further, I have a more general question (much like Murray posted one hour
ago on this newsgroup)... How can I diagnose Linker errors in general.
They don't necessarily tell you specifically what elements in your souruce
code correlate to the "unresolved external symbol." Is there a logical way
to make that determination?



Thanks, Bruce







------ Build started: Project: player-cpp, Configuration: Debug Win32 ------



Linking...

button.obj : error LNK2001: unresolved external symbol "void __cdecl
__CxxCallUnwindDtor(void (__thiscall*)(void *),void *)"
(?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

C:\...\cs-w-cpp\Debug\player-cpp.dll : fatal error LNK1120: 1 unresolved
externals





----------------------------------------------------------

--- button.h file ----------------------------------------





#pragma once



namespace nsPlayer

{

public __gc class Button

{

protected:

bool state;

public:

Button( bool initialState );

Button();

// virtual ~Button() = 0;

public:

virtual bool getState() = 0;

};



public __gc class ToggleButton : public Button

{

public:

ToggleButton();

ToggleButton( bool initialState );

~ToggleButton();

public:

bool getState();

bool push();

};



public __gc class DualButton : public Button

// The class represents a combination of two buttons that correspond to

// "on"/"off" or any other dual state, such as "play"/"stop", etc.

{

public:

DualButton();

DualButton( bool initialState );

~DualButton();

public:

bool getState();

void pushOnButton(); // push the "on" button.

void pushOffButton(); // push the "off" button.

};



}





----------------------------------------------------------

--- button.cpp file --------------------------------------



#include "stdafx.h"

#include "button.h"



namespace nsPlayer

{



Button::Button( bool initialState )

{

state = initialState;

}



Button::Button()

{

state = false;

}



// Button::~Button() {} // make it virtual??



//********************************************



ToggleButton::ToggleButton() : Button() {}

ToggleButton::ToggleButton( bool initialState ) : Button( initialState )
{}

ToggleButton::~ToggleButton() {}



bool ToggleButton::getState()

{

return state;

}



bool ToggleButton::push()

{

state = !state;

return state;

}



//********************************************



DualButton::DualButton() : Button() {}

DualButton::DualButton( bool initialState ) : Button( initialState ) {}

DualButton::~DualButton() {}



bool DualButton::getState()

{

return state;

}



void DualButton::pushOnButton()

// push the "on" button.

{

state = true;

}



void DualButton::pushOffButton()

// push the "off" button.

{

state = false;

}

}
 
W

William DePalo [MVP VC++]

Bruce Schechter said:
I am experimenting with managed code in C++. But shortly into my
exploration, I've run into a Linker error which I cannot diagnose. (I have
searched MS knowledgebase, MSDN newsgroups, and Google, with no luck.)

Are you building a mixed-mode DLL (one that conatins both managed and
unmanaged code)?

If so, take a look at this knowledge base article:

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

Regards,
Will
 
B

Bruce Schechter

Hello Will,

No, my project is not "mixed mode". I have no unmanaged code in the project
(unless something is going on here that I am not aware of.)

I do have a C# project that is interoperating with the MC++ project, but the
error message seems to be stating fairly clearly that the problem is within
the MC++ project, specifically in the code I posted. Further, the overall
project was working fine (including the interop of the C# UI with the MC++
business logic) until I introduced the Button class into the MC++ project..

So, in summary, it seems that the knowledge base article below is not
relevant to my situation. Anyone, please correct me if I am wrong.

Thanks again for the info, never-the-less.

Cheers, Bruce
 
G

Gary Chang

Hi Bruce,

How about the Button class in your MC++ project, is it a control like class?

And what's the usage of the destructor to its derived class you mentioned?


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
B

Bruce Schechter

Gary

It is not a control. Actually, the code was posted in my original message,
so you can see exactly what makes up the class. It is quite simple (since
it is just a starting point for a project at this point.)

The destructor is currently empty -- {}.

thanks, Bruce
 
G

Gary Chang

Hi Bruce,

Does any other class of(the current project) with the empty destructor have
that linker error?


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
B

Bruce Schechter

Gary,

Actually, I have since started exploring a different approach to the project
in which luckily I'm not seeing the same error message. (See "C++ and C#
interoperability" thread on this newsgroup.) So, I dont think I'll need to
finish this particular discussion.

Thanks!
Bruce
 
G

Gary Chang

Hi Bruce,

Thanks for your reply!
Actually, I have since started exploring a different approach to the project
in which luckily I'm not seeing the same error message. (See "C++ and C#
interoperability" thread on this newsgroup.) So, I don't think I'll need to
finish this particular discussion.

..., I agree with you, since I cannot repro the LNK2001 error on my side
with your sample code, it appears the problem is something else, It is a
better choice to try a different approach on this issue.

By the way, if you have more concern on this problem, please feel free to
reply this message.


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

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