1

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&)'|

Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53
  • `undefined reference to wxRichTextCtrl::wxRichTextCtrl(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&)'` – Marin Sagovac Jul 12 '14 at 15:11
  • I think wxRichTextCtrl can't be to Window or frame. wxTextCtrl works fine, but rich text not. – Marin Sagovac Jul 12 '14 at 15:12
  • Re-reading the error, it's actually a *linker* error. So are you linking with the library where the control is defined? Remember that wxWidgets is spread out in many different libraries. – Some programmer dude Jul 12 '14 at 15:14
  • Linker is `ar`. I've try to change `#include ` to `#include ` and says that not found. So only richtextctrl can't works for me, but works other control fine. It's wxWidgets 3.0 on Ubuntu 14.04. – Marin Sagovac Jul 12 '14 at 15:18
  • `ar` is a special command to create static libraries on POSIX systems, it's an abreviation of archiver. See e.g. [this page](http://docs.wxwidgets.org/trunk/page_libs.html) which lists the different libraries in a complete wxWidgets installation. Especially look for [this library](http://docs.wxwidgets.org/trunk/page_libs.html#page_libs_wxrichtext), which should give you some hints what to look for. – Some programmer dude Jul 12 '14 at 15:36
  • It's MONOLITIC not defined in gcc++ from GNU GCC compiler. I'm not sure how to setup from GNU GCC compiler. On wizard there aren't exists for version 3.0 and 2.8 – Marin Sagovac Jul 12 '14 at 22:57

2 Answers2

4

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.

VZ.
  • 21,740
  • 3
  • 39
  • 42
  • In a build options to other options in Codeblocks I've changed to: ``wx-config --libs richtext --cflags`` but it says that `lwx_gtk2u_richtext-3.0` no such file/dir – Marin Sagovac Jul 13 '14 at 12:40
  • Using terminal `wx-config --libs std,richtext` I got: `-L/usr/lib/i386-linux-gnu -pthread -lwx_gtk2u_richtext-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 ` but on Codeblocks it's top and didn't find library. – Marin Sagovac Jul 13 '14 at 12:41
  • I don't know what's going on with CB (what do you mean by "it's top"?) but you need to ensure that it uses this library. – VZ. Jul 13 '14 at 14:20
  • I've found problem. A code throwns errors from constructor because you have not m_richTextCtrl but a developers didn't support on wxWidgets 2.8 and above. I'm using 3.0 and `The code no longer works from 2.8.8 onwards. for wxRichTextCtrl`. "On top" means "is on going", "is setup already on C::B" – Marin Sagovac Jul 13 '14 at 14:48
  • 1
    This doesn't make any sense. You have a linking problem, what does this have to do with throwing anything from ctor? You probably need to open another question. – VZ. Jul 13 '14 at 15:05
3

In ubuntu 16.04 and code block Id Setting->compiler->linker Setting->add->browse( /usr/lib/x86_64-linux-gnu/libwx_gtk2u_richtext-3.0.so)

its work for me.