Re: [Dev-C++] Newbie linking errors: 'undefined reference'
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Devin C. <dcc...@ya...> - 2002-02-09 21:51:23
|
> BaseBook::Lookup(unsigned short, unsigned short) const
>
> Probably it has to do with the graphics library you use.
>
> Either there is no such thing in the library you use or if the construct
> is yours you have not provided a definition.
That's roughly what I thought. The function is, indeed, mine; I'm not
using a graphics library. (The game is that simple.) I do have a
definition in BaseBook.cpp. The definition refers to an object
contained in the private section of BaseBook, MoveParch, which has
its own Lookup function (I do it this way because subclasses of
BaseBook may want to redefine BaseBook::Lookup...
WomanQSPrototype.cpp is one of these subclasses.)
So plainly the linker isn't /reaching/ the definition. The method I
use does require a few daisy-chained functions (BaseBook::Lookup
calling MoveParch::Lookup, and there are other, three-step ones.)
I don't know if this could make a difference. It does not seem to
depend upon the legality of the code.
Ah. Genius lightbulb. Here's an example of something similar
from a few days back:
bool ManeuverList::SetManeuver( short int ManI, char* NameA, short int
BaseModA)
// Inlining this gives linker error 'Undefined reference
// to ManeuverList::Setmaneuver'. Gotcha!
// Same with the Index typedefl.
{
// Maneuver::Set checks to see if we can
// set this maneuver.
bool b;
b = ManVec[ManI].Set( NameA, BaseModA );
return b;
}
Index was typedefed as 'unsigned short int.' It worked perfectly
well elsewhere. That, and making this function inline caused the
undefined reference linker errors. Previously, I was having trouble
with size(): a while loop explicitly told me both A and B were false
(where B included a size() function,) and A && B was false, /but
while(A && B) would still run through./
I don't know if that's related. But it does show the level of
black-voodoo nbugs I'm running into. Two functions stopped giving
errors when the definitions were moved from the .cpp to the .h. An
undefined reference to the deconstructor went away when I moved
the deconstructor up a few lines! So whatever is wrong, it's subtle -
too subtle for me.
--Devin
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|