Search code examples
c++wxwidgets

wxRichTextCtrl not working?


Global *.h scope:

#include <wx/sizer.h>
#include <wx/window.h>
#include <wx/richtext/richtextctrl.h>

*.cpp file:

wxTextCtrl* daTextCtrl;
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);

wxFrame *frame2 = new wxFrame(NULL, -1, wxT("Dialog Title"), wxPoint(50, 50), wxSize(500, 500));
frame2->Show(true);

wxWindow *windo = new wxWindow(frame2, wxID_ANY, wxDefaultPosition, wxSize(500,500));

daTextCtrl = new wxRichTextCtrl(windo,
                    wxID_ANY,
                    _T("a"),
                    wxDefaultPosition,
                    wxSize(350,100),
                    wxVSCROLL);



windo->Show();

Error:

undefined reference to `wxRichTextCtrl::wxRichTextCtrl(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&)'|


Solution

  • You need to link with richtext library explicitly, it's not included in the default list of libraries output by wx-config --libs which you presumably use. I.e. you need wx-config --libs std,richtext.