Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > undefined reference to `vtable for Tuner' ??????

Reply
Thread Tools

undefined reference to `vtable for Tuner' ??????

 
 
alessandro
Guest
Posts: n/a
 
      09-13-2004
Compiling my current project I received the following error:
[Linker error] undefined reference to `vtable for Tuner'
The only two things I know are that the error occours when trying to invoke
the constructor of a class and that concerns virtual functions.
What does it mean?


 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      09-13-2004

"alessandro" <(E-Mail Removed)> wrote in message
news:Yph1d.245433$(E-Mail Removed)...
> Compiling my current project I received the following error:
> [Linker error] undefined reference to `vtable for Tuner'
> The only two things I know are that the error occours when trying to

invoke
> the constructor of a class and that concerns virtual functions.
> What does it mean?
>


Does Tuner or its bases have any virtual functions? Have you provided
definitions for them? It's worth trying a total rebuild for this sort of
problem.

John


 
Reply With Quote
 
 
 
 
alessandro
Guest
Posts: n/a
 
      09-13-2004
that's the definition of Tuner and it's base class:

class Tuner:Module
{
protected:
SDL_Surface* display; //Main lcd-like display

public:

static const unsigned int type = MODULE_NONE; //Holds a code that
specifies the module

Tuner(Sound* s, Graphic* g, Global* gl);
~Tuner();

virtual void Begin();
/*The following methods are called whenever an input event must be
notified
to the module instance.*/

virtual void MouseUp(Point* p);
virtual void MouseMove(Point* p)
{
mousepos.x = p->x;
mousepos.y = p->y;
}
};


class Module
{
protected:
bool running; //This thread is running
bool pause; //This thread is in pause

Sound* sound; //Global sound data
Graphic* graphic; //Global graphic data
Global* global; //Global variables

Point mousepos; //Position of the mouse

SDL_Surface* icon;

public:

static const unsigned int type = MODULE_NONE; //Holds a code that
specifies the module

Module(Sound* s, Graphic* g, Global* gl, char* iconname);

//~Module()

virtual void Begin();
SDL_Surface* GetIcon() { return icon; }

/*The following methods are called whenever an input event must be
notified
to the module instance.*/

virtual void MouseUp(Point* p) {};
virtual void MouseMove(Point* p)
{
mousepos.x = p->x;
mousepos.y = p->y;
}
};


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      09-13-2004

"alessandro" <(E-Mail Removed)> wrote in message
news:IIh1d.245584$(E-Mail Removed)...
> that's the definition of Tuner and it's base class:
>
> class Tuner:Module
> {
> protected:
> SDL_Surface* display; //Main lcd-like display
>
> public:
>
> static const unsigned int type = MODULE_NONE; //Holds a code that
> specifies the module
>
> Tuner(Sound* s, Graphic* g, Global* gl);
> ~Tuner();
>
> virtual void Begin();
> /*The following methods are called whenever an input event must be
> notified
> to the module instance.*/
>
> virtual void MouseUp(Point* p);
> virtual void MouseMove(Point* p)
> {
> mousepos.x = p->x;
> mousepos.y = p->y;
> }
> };
>
>
> class Module
> {
> protected:
> bool running; //This thread is running
> bool pause; //This thread is in pause
>
> Sound* sound; //Global sound data
> Graphic* graphic; //Global graphic data
> Global* global; //Global variables
>
> Point mousepos; //Position of the mouse
>
> SDL_Surface* icon;
>
> public:
>
> static const unsigned int type = MODULE_NONE; //Holds a code that
> specifies the module
>
> Module(Sound* s, Graphic* g, Global* gl, char* iconname);
>
> //~Module()
>
> virtual void Begin();
> SDL_Surface* GetIcon() { return icon; }
>
> /*The following methods are called whenever an input event must be
> notified
> to the module instance.*/
>
> virtual void MouseUp(Point* p) {};
> virtual void MouseMove(Point* p)
> {
> mousepos.x = p->x;
> mousepos.y = p->y;
> }
> };
>


Have you provided definitions for Tuner::Begin(), Tuner::MouseUp() and
Module::Begin() ? Every non-pure virtual function must always be defined
even if you don't call it.

john


 
Reply With Quote
 
alessandro
Guest
Posts: n/a
 
      09-13-2004
Yes...provided a definition for every non-pure virtual function. Them are
simply
funcname()
{
}

but that should be enaught. However these errors occour again. Note that
these are linker errors, all in the Tuner.o file (that is, the error occours
in the derived class).


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      09-13-2004

"alessandro" <(E-Mail Removed)> wrote in message
news:Hfi1d.245823$(E-Mail Removed)...
> Yes...provided a definition for every non-pure virtual function. Them are
> simply
> funcname()
> {
> }
>
> but that should be enaught. However these errors occour again. Note that
> these are linker errors, all in the Tuner.o file (that is, the error

occours
> in the derived class).
>


Well I'm not sure then. Plenty of people have had this error before

http://groups.google.co.uk/groups?ie...ined+reference

Commonest reason seems to be failing to define a virtual function, but have
a look for yourself.

john


 
Reply With Quote
 
Vyacheslav Kononenko
Guest
Posts: n/a
 
      09-13-2004
"alessandro" <(E-Mail Removed)> wrote in message
news:Hfi1d.245823$(E-Mail Removed)...
> Yes...provided a definition for every non-pure virtual function. Them are
> simply
> funcname()
> {
> }
>
> but that should be enaught. However these errors occour again. Note that
> these are linker errors, all in the Tuner.o file (that is, the error

occours
> in the derived class).
>

Are they in form funcname() or classname::funcname() ?

Regards,
Slava


 
Reply With Quote
 
alessandro
Guest
Posts: n/a
 
      09-14-2004
They are in form classname::funcname(). Now I'll install the latest mingw:
throught google I discovered that this is a pretty common error (but nobody
seems to be able to provide a solution or a workaround). Someone tells that
this error is given by a recent versione of gcc but not from the previous
ones, so I hope that using the newer available will fix the problem. Thank
yopu for the help



 
Reply With Quote
 
Howard
Guest
Posts: n/a
 
      09-14-2004

"alessandro" <(E-Mail Removed)> wrote in message
news:IIh1d.245584$(E-Mail Removed)...
> that's the definition of Tuner and it's base class:
>
> class Tuner:Module


Is this legal? I thought you had to specifiy the inheritance model also
(e.g., ": public Module)?

Also, is there a forward declaration of Module, or is this order you've
shown just for the purposes of posting here? As shown here, Tuner doesn't
yet know what Module is!

> {
> protected:
> SDL_Surface* display; //Main lcd-like display
>
> public:
>
> static const unsigned int type = MODULE_NONE; //Holds a code that
> specifies the module
>
> Tuner(Sound* s, Graphic* g, Global* gl);
> ~Tuner();
>
> virtual void Begin();
> /*The following methods are called whenever an input event must be
> notified
> to the module instance.*/
>
> virtual void MouseUp(Point* p);
> virtual void MouseMove(Point* p)
> {
> mousepos.x = p->x;
> mousepos.y = p->y;
> }
> };
>
>
> class Module
> {
> protected:
> bool running; //This thread is running
> bool pause; //This thread is in pause
>
> Sound* sound; //Global sound data
> Graphic* graphic; //Global graphic data
> Global* global; //Global variables
>
> Point mousepos; //Position of the mouse
>
> SDL_Surface* icon;
>
> public:
>
> static const unsigned int type = MODULE_NONE; //Holds a code that
> specifies the module
>
> Module(Sound* s, Graphic* g, Global* gl, char* iconname);
>
> //~Module()
>
> virtual void Begin();
> SDL_Surface* GetIcon() { return icon; }
>
> /*The following methods are called whenever an input event must be
> notified
> to the module instance.*/
>
> virtual void MouseUp(Point* p) {};
> virtual void MouseMove(Point* p)
> {
> mousepos.x = p->x;
> mousepos.y = p->y;
> }
> };
>


Most likely you haven't defined a function that is declared somewhere. How
about the destructor for Tuner...is it defined anywhere? I see you've
commented out the destructor declaration for Module. Did you mean to also
comment out Tuner's destructor declaration?

(By the way, if you're ever going to use a Module* pointer to instantiate a
Tuner object, then you should make the Module destructor virtual.)

-Howard


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      09-14-2004

"Howard" <(E-Mail Removed)> wrote in message
news:f5F1d.590129$(E-Mail Removed)...
>
> "alessandro" <(E-Mail Removed)> wrote in message
> news:IIh1d.245584$(E-Mail Removed)...
> > that's the definition of Tuner and it's base class:
> >
> > class Tuner:Module

>
> Is this legal? I thought you had to specify the inheritance model also
> (e.g., ": public Module)?



It's legal. Default is private inheritance for classes and public
inheritance for structs.

john


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
typeof x == 'undefined' or x == undefined? -Lost Javascript 13 01-31-2007 12:04 AM
undefined vs. undefined (was: new Array() vs []) VK Javascript 45 09-12-2006 05:26 PM
'Undefined' Client-Side Object Reference Felipe ASP .Net 3 07-16-2004 04:01 AM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM
Error: 'undefined reference' in g++ but gcc succeeded Lu C++ 1 07-10-2003 12:55 PM



Advertisments