linking problems

Jiann-Ming Su js1@microwave.ph.msstate.edu
Thu Apr 20 16:46:00 GMT 2000


I'm getting the following error:

SomeDerivedClass.o: In function `CSomeDerivedClass::Initialize(CSomeDerivedClass const &)':
/usr/include/g++-2/stl_algobase.h:121: undefined reference to `CSomeDerivedClass::MemberFunction(void)'
collect2: ld returned 1 exit status
make: *** [simulator] Error 1

The MemberFunction() function is a virtual function with no arguments.
In the SomeDerivedClass.cpp file:

/////////////////////////////////////////////////////////////////////////////
// Function:    Initialize(const CSomeDerivedClass& a_rObjectToInitializeFrom)
// Arguements:  const CSomeDerivedClass& a_rObjectToInitializeFrom
// Return Type: Void.
// Description: Common initialization routine used by various constructors
//              and and the assignment operator.
// Revisions:   4/1/2000  -  Original creation.
/////////////////////////////////////////////////////////////////////////////
void CSomeDerivedClass::Initialize(const CSomeDerivedClass& a_rObjectToInitializeFrom)
{
	m_attribute1 = a_rObjectToInitializeFrom.m_attribute1;
	m_attribute2 = a_rObjectToInitializeFrom.attribute2;
	m_attribute3  = a_rObjectToInitializeFrom.m_attribute3;

}

The strange thing is this code had linked previously.  I've added new
code, but none relating to this function.  The objects compile with
no problems, but linking now fails.  I'm using egcs-2.91.66 on a Linux
system.  Thanks for any help.

Jiann-Ming Su, js1@microwave.ph.msstate.edu
Criminals, by definition, break the law...



More information about the Gcc mailing list