HELP: wxValidator and undefined reference to `vtable ...` under linux

Discussion in 'C++' started by Quansheng Liang, May 24, 2004.

  1. Hello,
    I struggled with the problem of "undefined reference to `vtable ...`"
    while migrating a project from windows to linux. After searching the
    google I removed all the inline functions and now the link errors
    decreased from over 200 to 5. A great step!
    But one of my class derived from wxValidator can't be linked correctly
    though there is no any inline function in it.

    The error message:
    -----------------------
    Linking...
    /home/qsliang/projects/ezData/Debug/validator.o(.text+0x19): In
    function `ezValidatorLong::ezValidatorLong[not-in-charge](long*)':
    /usr/local/include/wx/string.h:717: undefined reference to `vtable for
    ezValidatorLong'
    /home/qsliang/projects/ezData/Debug/validator.o(.text+0x55): In
    function `ezValidatorLong::ezValidatorLong[in-charge](long*)':
    src/helper/validator.cpp:22: undefined reference to `vtable for
    ezValidatorLong'
    /home/qsliang/projects/ezData/Debug/validator.o(.text+0x91): In
    function `ezValidatorLong::ezValidatorLong[not-in-charge](long*, long,
    long)':
    src/helper/validator.cpp:27: undefined reference to `vtable for
    ezValidatorLong'
    /home/qsliang/projects/ezData/Debug/validator.o(.text+0xcb): In
    function `ezValidatorLong::ezValidatorLong[in-charge](long*, long,
    long)':
    src/helper/validator.cpp:27: undefined reference to `vtable for
    ezValidatorLong'

    My class (in two files):
    ------------------------
    class ezValidatorLong : public wxValidator
    {
    private:
    long *mpValue, mMin, mMax;

    public:
    ezValidatorLong(long *pValue);
    ezValidatorLong(long *pValue, long xMin, long xMax);
    // ~ezValidatorLong();

    wxObject* Clone() const;
    bool Validate(wxWindow* pParent);
    bool TransferFromWindow();
    bool TransferToWindow();
    };
    ezValidatorLong::ezValidatorLong(long *pValue)
    { mpValue = pValue;
    mMin = 1;
    mMax = 0;
    }
    ezValidatorLong::ezValidatorLong(long *pValue, long xMin, long xMax)
    { mpValue = pValue;
    mMin = xMin;
    mMax = xMax;
    }
    //ezValidatorLong::~ezValidatorLong(){}
    wxObject* ezValidatorLong::Clone() const
    { return new ezValidatorLong(mpValue,mMin,mMax);
    }

    bool ezValidatorLong::Validate(wxWindow*)
    { return // do-check //;
    }

    bool ezValidatorLong::TransferFromWindow()
    { wxString s = ((wxTextCtrl*)GetWindow())->GetValue();
    s.ToLong(mpValue);
    return true;
    }
    bool ezValidatorLong::TransferToWindow()
    { wxString s;
    s.Printf("%ld",*mpValue);
    ((wxTextCtrl*)GetWindow())->SetValue(s);
    return true;
    }

    --------------------------
    The destructor, Clone(), Validate(), Transfer..Window() in wxValidator
    are virtual. In my class, I got the same result no matter if there is
    a destructor.
    In the project, wxValidator is also used directly muliple times
    without problem.

    Any suggestion will be highly appreciated!
    Liang
     
    Quansheng Liang, May 24, 2004
    #1
    1. Advertising

  2. Re: wxValidator and undefined reference to `vtable ...` under linux

    g++ ... -fvtable-thunks ...

    BTW, that's OT here...

    -Gernot
     
    Gernot Frisch, May 25, 2004
    #2
    1. Advertising

  3. The problem solved:
    by adding
    #pragma implementation "validator.h"
    in the front of the validator.cpp.
    What's the statement mean?
    Liang

    (Quansheng Liang) wrote in message news:<>...
    > Hello,
    > I struggled with the problem of "undefined reference to `vtable ...`"
    > while migrating a project from windows to linux. After searching the
    > google I removed all the inline functions and now the link errors
    > decreased from over 200 to 5. A great step!
    > But one of my class derived from wxValidator can't be linked correctly
    > though there is no any inline function in it.
    >
    > The error message:
    > -----------------------
    > Linking...
    > /home/qsliang/projects/ezData/Debug/validator.o(.text+0x19): In
    > function `ezValidatorLong::ezValidatorLong[not-in-charge](long*)':
    > /usr/local/include/wx/string.h:717: undefined reference to `vtable for
    > ezValidatorLong'
    > /home/qsliang/projects/ezData/Debug/validator.o(.text+0x55): In
    > function `ezValidatorLong::ezValidatorLong[in-charge](long*)':
    > src/helper/validator.cpp:22: undefined reference to `vtable for
    > ezValidatorLong'
    > /home/qsliang/projects/ezData/Debug/validator.o(.text+0x91): In
    > function `ezValidatorLong::ezValidatorLong[not-in-charge](long*, long,
    > long)':
    > src/helper/validator.cpp:27: undefined reference to `vtable for
    > ezValidatorLong'
    > /home/qsliang/projects/ezData/Debug/validator.o(.text+0xcb): In
    > function `ezValidatorLong::ezValidatorLong[in-charge](long*, long,
    > long)':
    > src/helper/validator.cpp:27: undefined reference to `vtable for
    > ezValidatorLong'
    >
    > My class (in two files):
    > ------------------------
    > class ezValidatorLong : public wxValidator
    > {
    > private:
    > long *mpValue, mMin, mMax;
    >
    > public:
    > ezValidatorLong(long *pValue);
    > ezValidatorLong(long *pValue, long xMin, long xMax);
    > // ~ezValidatorLong();
    >
    > wxObject* Clone() const;
    > bool Validate(wxWindow* pParent);
    > bool TransferFromWindow();
    > bool TransferToWindow();
    > };
    > ezValidatorLong::ezValidatorLong(long *pValue)
    > { mpValue = pValue;
    > mMin = 1;
    > mMax = 0;
    > }
    > ezValidatorLong::ezValidatorLong(long *pValue, long xMin, long xMax)
    > { mpValue = pValue;
    > mMin = xMin;
    > mMax = xMax;
    > }
    > //ezValidatorLong::~ezValidatorLong(){}
    > wxObject* ezValidatorLong::Clone() const
    > { return new ezValidatorLong(mpValue,mMin,mMax);
    > }
    >
    > bool ezValidatorLong::Validate(wxWindow*)
    > { return // do-check //;
    > }
    >
    > bool ezValidatorLong::TransferFromWindow()
    > { wxString s = ((wxTextCtrl*)GetWindow())->GetValue();
    > s.ToLong(mpValue);
    > return true;
    > }
    > bool ezValidatorLong::TransferToWindow()
    > { wxString s;
    > s.Printf("%ld",*mpValue);
    > ((wxTextCtrl*)GetWindow())->SetValue(s);
    > return true;
    > }
    >
    > --------------------------
    > The destructor, Clone(), Validate(), Transfer..Window() in wxValidator
    > are virtual. In my class, I got the same result no matter if there is
    > a destructor.
    > In the project, wxValidator is also used directly muliple times
    > without problem.
    >
    > Any suggestion will be highly appreciated!
    > Liang
     
    Quansheng Liang, May 25, 2004
    #3
    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,948
    Artie Gold
    Aug 1, 2003
  2. bp
    Replies:
    3
    Views:
    20,742
    Rolf Magnus
    Aug 20, 2004
  3. alessandro
    Replies:
    9
    Views:
    6,094
    John Harrison
    Sep 14, 2004
  4. Karl Ebener

    Undefined reference to vtable

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

Share This Page