undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Rob'
Experienced Solver
Experienced Solver
Posts: 68
Joined: Mon Dec 08, 2008 10:10 pm

undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by Rob' »

I have a class derived from wxGridCellEditor with an overloaded BeginEdit() method. In this method I added one line, the rest is the same as in the base class.

Code: Select all

void gsErrPropsEditor::BeginEdit(int row, int col, wxGrid* grid)
{
  wxASSERT_MSG(m_control, wxT("The wxGridCellEditor must be created first!"));

  wxGridCellEditorEvtHandler* evtHandler = NULL;
  if (m_control)
    evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler); <==== Linker error

  // Don't immediately end if we get a kill focus event within BeginEdit
  if (evtHandler)
    evtHandler->SetInSetFocus(true);

  Id = wxAtoi(grid->GetTable()->GetValue(row, col));  // Id Text aus dem Grid

  Reset(); // this updates combo box to correspond to m_value

  Combo()->SetFocus();

#ifdef __WXOSX_COCOA__
  // This is a work around for the combobox being simply dismissed when a
  // choice is made in it under OS X. The bug is almost certainly due to a
  // problem in focus events generation logic but it's not obvious to fix and
  // for now this at least allows to use wxGrid.
  Combo()->Popup();
#endif

  if (evtHandler)
  {
    // When dropping down the menu, a kill focus event
    // happens after this point, so we can't reset the flag yet.
#if !defined(__WXGTK20__)
    evtHandler->SetInSetFocus(false);
#endif
  }
}
The marked line produces the above-mentioned linker error. What could be the reason? I'm using wx 3.1 and TDM-GCC 5.1.

Thanks in advance.
Rob'
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by doublemax »

Show the header file for gsErrPropsEditor.
Use the source, Luke!
Rob'
Experienced Solver
Experienced Solver
Posts: 68
Joined: Mon Dec 08, 2008 10:10 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by Rob' »

This is a part from the header file, it contain some more class deklarations:

Code: Select all

#include <wx/string.h>
#include <vector>
#include <wx/arrstr.h>
#include <wx/grid.h>
#include "errwindowbase.h"
...
class gsErrPropsEditor : public wxGridCellEditor
{
public:
  gsErrPropsEditor(gsErrProps* errprops);

  virtual void Create(wxWindow* parent,
                      wxWindowID id,
                      wxEvtHandler* evtHandler);

  virtual void SetSize(const wxRect& rect);

  virtual void PaintBackground(wxDC& dc,
                               const wxRect& rectCell,
                               const wxGridCellAttr& attr);

  virtual void BeginEdit(int row, int col, wxGrid* grid);
  virtual bool EndEdit(int row, int col, const wxGrid* grid,
                       const wxString& oldval, wxString *newval);
  virtual void ApplyEdit(int row, int col, wxGrid* grid);

  virtual void Reset();

  virtual wxGridCellEditor *Clone() const;

  // added GetValue so we can get the value which is in the control
  virtual wxString GetValue() const;

  void Aktualisieren(); // füllt die Auswahlliste

protected:
  wxComboBox *Combo() const { return (wxComboBox *)m_control; }

  gsErrProps*     ErrProps;
  int             Id; // Id des aktuell in der Zelle enthaltenen Items

//  wxDECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor);
};
I forgot to mention, that this is working well with wxWidgets 3.0 and GCC 4.8 (the wxPack installation).

Rob'
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by doublemax »

Sorry, no idea.
this is working well with wxWidgets 3.0 and GCC 4.8
It might be interesting to find out if it's the wxWidgets or compiler version that makes the difference.
Use the source, Luke!
Rob'
Experienced Solver
Experienced Solver
Posts: 68
Joined: Mon Dec 08, 2008 10:10 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by Rob' »

I found some using of wxObject::ms_classInfo in the source, but any declaration (wether in WX 3.0 nor in WX 3.1). Where/how is it declared?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by doublemax »

ms_classInfo etc. is added to a class via one of the DECLARE_DYNAMIC_CLASS macros. But as you derive from wxGridCellEditor, it should already be in there.
Use the source, Luke!
Rob'
Experienced Solver
Experienced Solver
Posts: 68
Joined: Mon Dec 08, 2008 10:10 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by Rob' »

I have added the wxIMPLEMENT_DYNAMIC_CLASS macro and get now the following error:

Code: Select all

C:\dev\wxWidgets3.1\include\wx\rtti.h|153|error: 'wxClassInfo gsErrPropsEditor::ms_classInfo' is not a static data member of 'class gsErrPropsEditor'|
That confirms my suspect, but the question remains: Why not? What flags I have to set, when I compile wxWidgets? The USE_RTTI flag is already set to 1 in the config.gcc. Are there any other settings necessary?

Rob'
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by doublemax »

Can you create a minimal, compilable sample that shows the linker error?
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by PB »

Just curious: If you use C++'s dynamic_cast instead of wxDynamicCast, does your application build and run as expected?

BTW, the linker-reported issue is with wxGridCellEditorEvtHandler::ms_classInfo, so it should have nothing to do with your editor class.
Rob'
Experienced Solver
Experienced Solver
Posts: 68
Joined: Mon Dec 08, 2008 10:10 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by Rob' »

It is not so easy, because gsErrPropsEditor is part of a library that I use for my projects. Thanks so far, I will get back here.

Rob'
wxProject
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Jul 20, 2022 11:31 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by wxProject »

is anyone can fix this bug
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by ONEEYEMAN »

Hi,
This thread is old.
You should have made new thread and give more info.

Thank you.
wxProject
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Jul 20, 2022 11:31 pm

Re: undefined reference to wxGridCellEditorEvtHandler::ms_classInfo

Post by wxProject »

use static_cast instead of wxDynamicCast
Post Reply