By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
g++ ... -fvtable-thunks ...

BTW, that's OT here...

-Gernot
Jul 22 '05 #2

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

li***@ezget.net (Quansheng Liang) wrote in message news:<30**************************@posting.google. com>...
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

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.