undefined reference to vtable
-
- Knows some wx things
- Posts: 28
- Joined: Tue Oct 18, 2005 7:52 am
undefined reference to vtable
I use wxDev-Cpp beta 6.8 (with mingw 3.4 and wxwidgets 2.6.1)
I have defined a derived Class of wxComboBox, and I obtain a linker error:
undefined reference to `vtable for MyComboBox'
How can avoid this problem?
thanks
I have defined a derived Class of wxComboBox, and I obtain a linker error:
undefined reference to `vtable for MyComboBox'
How can avoid this problem?
thanks
It helps by showing some (stripped down) code. Remember, even pragma's can cause this. Are you using the #pragma implementation part by any chance?
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- Knows some wx things
- Posts: 28
- Joined: Tue Oct 18, 2005 7:52 am
Here is my header file:lowjoel wrote:if you called DECLARE_EVENT_TABLE() in MyComboBox, make sure you defined an event table for MyComboBox
Code: Select all
#ifndef MYCOMBOBOX_H
#define MYCOMBOBOX_H
#include <wx/combobox.h> // inheriting class's header file
/*
* No description
*/
class MyComboBox : public wxComboBox
{
public:
// class constructor
MyComboBox(wxWindow* parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
: wxComboBox(parent, id, value, pos, size, choices, style,
validator, name) { };
// class destructor
~MyComboBox();
protected:
void OnFocusGot(wxFocusEvent& event);
private:
DECLARE_EVENT_TABLE();
};
#endif // MYCOMBOBOX_H
Code: Select all
#include "mycombobox.h" // class's header file
BEGIN_EVENT_TABLE(MyComboBox, wxComboBox)
EVT_SET_FOCUS(MyComboBox::OnFocusGot)
END_EVENT_TABLE()
void MyComboBox::OnFocusGot(wxFocusEvent& event)
{
// insert your code here
}
Code: Select all
g++.exe vsendppDlg.o vsendppApp.o mycombobox.o vsendpp_private.res -o "vsendpp.exe" -L"C:/Dev-Cpp/lib" -mwindows -lwxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32 -lopengl32
thanks
Last edited by mastupristi on Tue Oct 25, 2005 7:13 am, edited 1 time in total.
-
- Knows some wx things
- Posts: 28
- Joined: Tue Oct 18, 2005 7:52 am
I think your'd better check for something like "#pragma interface" in your code.mastupristi wrote:I don't think (if wxDev-Cpp hasn't add it).Jorg wrote:It helps by showing some (stripped down) code. Remember, even pragma's can cause this. Are you using the #pragma implementation part by any chance?
thanks
Maybe you just didn't post the code, but the destructor is declared but not defined. If so, that would give the error message.
If that's not it, 2 other suggestions. Remove the unnecessary semi-colons after the constructor and after DECLARE_EVENT_TABLE(). This doesn't cause the error for me using linux, but maybe in your setup . . . . .
Failing that, remove everything
. Try just class MyComboBox : public wxComboBox{}; If that still fails, you'll know it's not your code. If it works, add things back one by one until the error recurs.
HTH,
David
If that's not it, 2 other suggestions. Remove the unnecessary semi-colons after the constructor and after DECLARE_EVENT_TABLE(). This doesn't cause the error for me using linux, but maybe in your setup . . . . .
Failing that, remove everything

HTH,
David
That'd be it. I get that compile error all the time cause I declare a destructor out of habit but then forget to define it if I don't need it.DavidHart wrote:Maybe you just didn't post the code, but the destructor is declared but not defined. If so, that would give the error message.
[INSERT LAME SIG HERE]