Re: Signal handler problem while linking



Am Freitag, den 02.02.2007, 22:45 +0100 schrieb Tomek Lorek:
> Hi there,
> I've got another thing that I can't go through: my sources are
> compiling properly but the final linking fails with:
> addtask.o: In function `AddTask::AddTask(Glib::RefPtr<Gnome::Glade::Xml>)':
> addtask.cpp:(.text+0x490): undefined reference to `AddTask::on_ok_clicked()'
> addtask.cpp:(.text+0x54a): undefined reference to `AddTask::on_cancel_clicked()'
> addtask.cpp:(.text+0x604): undefined reference to
> `AddTask::on_open_calendar_clicked()'

The linker message says it all: you need to provide implementations of
these methods, not just the declarations.

[snip]
>    if (m_wOpenCalendar) {
>       m_wOpenCalendar->signal_clicked().connect(SigC::slot(&on_open_calendar_clicked));
>    }
> }
> 
> I had to make my signal handlers static, because it was impossible to
> make a reference to a non-static member.

Use SigC::slot(*this, &AddTask::on_ok_clicked) to connect a non-static
method.  By the way, you must be using pretty old versions of gtkmm and
libsigc++, since the syntax changed from SigC::Slot() to sigc::mem_fun()
quite a while ago.

--Daniel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]