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:ush()
{
state = !state;
return state;
}
//********************************************
DualButton:ualButton() : Button() {}
DualButton:ualButton( bool initialState ) : Button( initialState ) {}
DualButton::~DualButton() {}
bool DualButton::getState()
{
return state;
}
void DualButton:ushOnButton()
// push the "on" button.
{
state = true;
}
void DualButton:ushOffButton()
// push the "off" button.
{
state = false;
}
}
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:ush()
{
state = !state;
return state;
}
//********************************************
DualButton:ualButton() : Button() {}
DualButton:ualButton( bool initialState ) : Button( initialState ) {}
DualButton::~DualButton() {}
bool DualButton::getState()
{
return state;
}
void DualButton:ushOnButton()
// push the "on" button.
{
state = true;
}
void DualButton:ushOffButton()
// push the "off" button.
{
state = false;
}
}