undefined reference to `vtable for ...

Discussion in 'C++' started by bp, Aug 20, 2004.

  1. bp

    bp Guest

    Hi,

    Could someone to tell me what I'm doing wrong? I'm using
    gcc version 3.3.4 and
    ld version 2.15.90.0.3 20040415

    the linker message is:

    .../obj/classOpenAreaForm.o(.text+0x211): In function
    `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
    .../src/appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
    for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In function
    `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':

    .../appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable for
    TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x4ce): In function
    `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*, int, int, int,
    int, char const*)':

    .../src/appforms/classOpenAreaForm.cpp:86: undefined reference to `vtable
    for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x638): In function
    `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*, int, int, int, int,
    char const*)':

    .../src/appforms/classOpenAreaForm.cpp:86: undefined reference to `vtable
    for TOpenAreaForm' collect2: ld returned 1 exit status

    the headers of the involved classes:

    TControl.h
    ______________
    #ifndef __CONTROL_HPP_
    #define __CONTROL_HPP_

    class TControl
    {
    protected:
    TControl *parent;
    .....
    public:
    TControl(TControl *parent_);
    TControl(TControl *parent_, int left_,int top_,
    int width_,int height_,const char* caption_='\0');
    virtual ~TControl(void);
    ....
    };
    #endif
    --------------------

    TForm.h
    _________________
    #include "classControl.hpp"

    class TForm : public TControl {
    protected:
    virtual void Draw(void);
    public:
    TForm(TControl *parent_);
    TForm(TControl *parent_, int left_, int top_, int width_,
    int height_, const char* caption_);
    .......
    };
    ....
    #endif

    --------------------
    TOpenAreaForm.h
    _________________
    #ifndef __OPENAREAFORM_HPP_
    #define __OPENAREAFORM_HPP_
    #include "../appgui/classForm.hpp"
    // forward declaration
    class TListView;

    class TOpenAreaForm : public TForm {
    public:
    TOpenAreaForm(TControl *parent_);
    TOpenAreaForm(TControl *parent_, int left_, int top_,
    int width_, int height_, const char* caption_);
    ~TOpenAreaForm(void);
    TListView* filelist;
    void RefreshListItems(void);
    };
    ....
    #endif

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

    Thanks
     
    bp, Aug 20, 2004
    #1
    1. Advertising

  2. bp

    bp Guest

    On Fri, 20 Aug 2004 15:49:38 -0400, Xenos wrote:

    > I don't know if this will help you, but I got this one time when I declared
    > a virtual member but failed to define it.


    It helped.
    Thank you
     
    bp, Aug 20, 2004
    #2
    1. Advertising

  3. bp

    Xenos Guest

    "bp" <> wrote in message
    news:p...
    > Hi,
    >
    > Could someone to tell me what I'm doing wrong? I'm using
    > gcc version 3.3.4 and
    > ld version 2.15.90.0.3 20040415
    >
    > the linker message is:
    >
    > ../obj/classOpenAreaForm.o(.text+0x211): In function
    > `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
    > ../src/appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
    > for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In function
    > `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':
    >

    I don't know if this will help you, but I got this one time when I declared
    a virtual member but failed to define it.
     
    Xenos, Aug 20, 2004
    #3
  4. bp

    Rolf Magnus Guest

    bp wrote:

    > Hi,
    >
    > Could someone to tell me what I'm doing wrong? I'm using
    > gcc version 3.3.4 and
    > ld version 2.15.90.0.3 20040415
    >
    > the linker message is:
    >
    > ../obj/classOpenAreaForm.o(.text+0x211): In function
    > `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
    > ../src/appforms/classOpenAreaForm.cpp:66: undefined reference to
    > `vtable for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In
    > function `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':
    >
    > ../appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
    > for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x4ce): In
    > function `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*, int,
    > int, int, int, char const*)':
    >
    > ../src/appforms/classOpenAreaForm.cpp:86: undefined reference to
    > `vtable for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x638): In
    > function `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*, int, int,
    > int, int, char const*)':
    >
    > ../src/appforms/classOpenAreaForm.cpp:86: undefined reference to
    > `vtable for TOpenAreaForm' collect2: ld returned 1 exit status
    >
    > the headers of the involved classes:
    >
    > TControl.h
    > ______________
    > #ifndef __CONTROL_HPP_
    > #define __CONTROL_HPP_


    Identifiers containing two consecutive underscores are reserved for the
    implementation (i.e. the compiler and its standard library). You are
    not allowed to define any of those yourself.

    > class TControl
    > {
    > protected:
    > TControl *parent;
    > ....
    > public:
    > TControl(TControl *parent_);
    > TControl(TControl *parent_, int left_,int top_,
    > int width_,int height_,const char* caption_='\0');


    That might not do what you expect it to. '\0' is usually used as a
    string termination character - a character with the value 0. But your
    char* will not be assigned the address of such a 0 character. Rather it
    will become a null pointer, since '\0' would just be an integer with
    the value zero, which is in a pointer context interepreted a null
    pointer constant, and _not_ a character constant. What you might have
    wanted is:

    TControl(TControl *parent_, int left_,int top_,
    int width_,int height_,const char* caption_="");


    > virtual ~TControl(void);
    > ....
    > };
    > #endif
    > --------------------
    >
    > TForm.h
    > _________________
    > #include "classControl.hpp"
    >
    > class TForm : public TControl {
    > protected:
    > virtual void Draw(void);


    Is that Draw() member function actually defined anywhere?

    > public:
    > TForm(TControl *parent_);
    > TForm(TControl *parent_, int left_, int top_, int width_,
    > int height_, const char* caption_);
    > ......
    > };
    > ...
    > #endif
    >
    > --------------------
    > TOpenAreaForm.h
    > _________________
    > #ifndef __OPENAREAFORM_HPP_
    > #define __OPENAREAFORM_HPP_
    > #include "../appgui/classForm.hpp"
    > // forward declaration
    > class TListView;
    >
    > class TOpenAreaForm : public TForm {
    > public:
    > TOpenAreaForm(TControl *parent_);
    > TOpenAreaForm(TControl *parent_, int left_, int top_,
    > int width_, int height_, const char* caption_);
    > ~TOpenAreaForm(void);
    > TListView* filelist;
    > void RefreshListItems(void);
    > };
    > ...
    > #endif
    >
    > ------------
    >
    > Thanks


    --
    This project is so important, we can't let things that are more
    important interfere with it.
    (Advertising/Marketing manager, United Parcel Service)
     
    Rolf Magnus, Aug 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Heiserer
    Replies:
    1
    Views:
    2,957
    Artie Gold
    Aug 1, 2003
  2. Quansheng Liang
    Replies:
    2
    Views:
    584
    Quansheng Liang
    May 25, 2004
  3. alessandro
    Replies:
    9
    Views:
    6,104
    John Harrison
    Sep 14, 2004
  4. Karl Ebener

    Undefined reference to vtable

    Karl Ebener, Nov 19, 2004, in forum: C++
    Replies:
    6
    Views:
    49,596
    Karl Ebener
    Nov 19, 2004
  5. jimjim
    Replies:
    9
    Views:
    755
    jimjim
    Aug 12, 2005
Loading...

Share This Page