wxMSW 2.8.7 and DECLARE/DEFINE_EVENT_TYPE and shared libs
Matthias Buelow
mkb at incubus.de
Wed May 21 07:15:00 PDT 2008
Hi folks,
there seems to be a discrepancy on MSW when using shared libs and
defining/declaring new event types, which leads to unresolved symbol(s)
during linking. In particular, I have the following event
declaration/definition:
In file a.h:
...
#include <wx/event.h>
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(fooMSG_EVENT, -1);
END_DECLARE_EVENT_TYPES()
...
and in file a.cpp:
...
DEFINE_EVENT_TYPE(fooMSG_EVENT)
...
Now, if I include a.h in another file b.cpp and try to use the event
type in an event table, I get from the linker:
... undefined reference to `_imp__fooMSG_EVENT'
In wx-2.8/wx/event.h, the macros apparently get defined as following:
#define DECLARE_EVENT_TYPE(name, value) \
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
where WXDLLIMPEXP_CORE apparently effects that the name gets prefixed
with _imp__, whereas the DEFINE macro:
#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
doesn't rewrite the name, hence the mismatch. What am I doing wrong? I'm
naive about (wx)MSW and any dynamic linking particularities on that
platform, so any idea is appreciated. Meanwhile, I have hand-expanded
the DECLARE macro without the WXDLLIMPEXP_CORE and simply use:
extern const wxEventType fooMSG_EVENT;
instead, which seems to work.
More information about the wx-users
mailing list