Author Topic: Compiling wxWidgets contrib and wxcode sources  (Read 5797 times)

Offline New Pagodi

  • Multiple posting newcomer
  • *
  • Posts: 41
Compiling wxWidgets contrib and wxcode sources
« on: June 19, 2006, 05:39:06 pm »
Hello, and thanks to the administrators for running this forum.  I’m still relatively new to Code::Blocks, so I apologize if this is something I should know.  Basically, I can compile the wxWidgets contrib and wxcode sources successfully using the Code::Block’s wxWidgets “using static library” template, but when I try to compile them with one of the “using wxWidgets dll” templates I run into a dilemma.

Using the template’s default options, the source files will not compile.  If I remove WXUSINGDLL option from the complier’s #define options, the sources will compile, but the project will not link.

Is it possible to use the “using wxWigets dll” templates when using these custom controls, or do you have to use the static library templates in these cases?

In case these will be helpful, here is a sampling of the errors I get when using the defaults:
Code
treelistctrl.cpp:92: warning: 'wxTreeListCtrlNameStr' defined locally after being referenced with dllimport linkage
treelistctrl.cpp:4109: error: definition of static data member 'wxTreeListCtrl::ms_classInfo' of dllimport'd class.
treelistctrl.cpp:4109: warning: function 'static wxObject* wxTreeListCtrl::wxCreateObject()' is defined after prior declaration as dllimport: attribute ignored
treelistctrl.cpp:4109: warning: 'static wxObject* wxTreeListCtrl::wxCreateObject()' defined locally after being referenced with dllimport linkage
treelistctrl.cpp:4111: error: definition of static data member 'wxTreeListCtrl::sm_eventTable' of dllimport'd class.
treelistctrl.cpp:4111: error: definition of static data member 'wxTreeListCtrl::sm_eventHashTable' of dllimport'd class.
treelistctrl.cpp:4111: error: definition of static data member 'wxTreeListCtrl::sm_eventTableEntries' of dllimport'd class.
treelistctrl.cpp:4111: warning: 'wxTreeListCtrl::sm_eventTableEntries' defined locally after being referenced with dllimport linkage

And here are some of the errors I get with WXUSINGDLL removed:
Code
.objs\treelistctrl.o(.text$_ZN8wxWindowC2EPS_iRK7wxPointRK6wxSizelRK8wxString[wxWindow::wxWindow(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)]+0x4c):treelistctrl.cpp: variable 'vtable for wxWindow' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
.objs\treelistctrl.o(.text$_ZN8wxObjectC2ERKS_[wxObject::wxObject(wxObject const&)]+0xb):treelistctrl.cpp: variable 'vtable for wxObject' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
.objs\treelistctrl.o(.text$_ZN7wxTimerC2Ev[wxTimer::wxTimer()]+0x4c):treelistctrl.cpp: variable 'vtable for wxTimer' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
.objs\treelistctrl.o(.text$_ZN11wxTimerBaseC2Ev[wxTimerBase::wxTimerBase()]+0x16):treelistctrl.cpp: variable 'vtable for wxTimerBase' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
...
.objs\treelisttest.o(.text+0x4e1c):treelisttest.cpp: undefined reference to `_imp__wxTreeListCtrlNameStr'
.objs\treelisttest.o(.text+0x5185):treelisttest.cpp: undefined reference to `_imp___ZN14wxTreeListCtrl17SetColumnEditableEib'

Thanks

Offline New Pagodi

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Compiling wxWidgets contrib and wxcode sources
« Reply #1 on: June 23, 2006, 01:59:46 am »
In case any one is interested, the problem is that the contrib sources usually use a bunch of weird storage class types for their classes.  For example, the plot contrib source uses the ‘WXDLLIMPEXP_PLOT’ like so:
Code
 class WXDLLIMPEXP_PLOT wxPlotEvent;
  These storage class types are supposed to resolve to nothing, __declspec( dllimport ), or__declspec( dllexport ) depending on the defines that are used in your project. To get the source to compile with a stand alone project, they need to resolve to nothing. However, an unfortunate side effect of the WXUSINGDLL define that is used with the “using wxWidgets dll” templates is to make them resolve to __declspec( dllimport ). 

So far, the only way around this is to manually edit the source files.  Near the beginning there is usually a set of macros like this
Code
 #ifdef WXMAKINGDLL_PLOT
    #define WXDLLIMPEXP_PLOT WXEXPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXEXPORT type
#elif defined(WXUSINGDLL)
    #define WXDLLIMPEXP_PLOT WXIMPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXIMPORT type
#else // not making nor using DLL
    #define WXDLLIMPEXP_PLOT
    #define WXDLLIMPEXP_DATA_PLOT(type) type
#endif
that begin the process of resolving the storage class types to what they are supposed to be.  To make them resolve to nothing when WXUSINGDLL is used, the macros can be changed to something like this:
Code
 #ifdef WXMAKINGDLL_PLOT
    #define WXDLLIMPEXP_PLOT WXEXPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXEXPORT type
#elif defined(WXUSINGDLL) && !defined(ADHOCDEFINE77)
    #define WXDLLIMPEXP_PLOT WXIMPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXIMPORT type
#else // not making nor using DLL
    #define WXDLLIMPEXP_PLOT
    #define WXDLLIMPEXP_DATA_PLOT(type) type
#endif
Then add ADHOCDEFINE77 to the compiler defines under Project->Build Options->Compiler->#defines.   


Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: Compiling wxWidgets contrib and wxcode sources
« Reply #2 on: June 23, 2006, 03:34:43 am »
To make them resolve to nothing when WXUSINGDLL is used, the macros can be changed to something like this:
Code
 #ifdef WXMAKINGDLL_PLOT
    #define WXDLLIMPEXP_PLOT WXEXPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXEXPORT type
#elif defined(WXUSINGDLL) && !defined(ADHOCDEFINE77)
    #define WXDLLIMPEXP_PLOT WXIMPORT
    #define WXDLLIMPEXP_DATA_PLOT(type) WXIMPORT type
#else // not making nor using DLL
    #define WXDLLIMPEXP_PLOT
    #define WXDLLIMPEXP_DATA_PLOT(type) type
#endif
Then add ADHOCDEFINE77 to the compiler defines under Project->Build Options->Compiler->#defines.   



Thanks for that. Would have liked to have had that advice when I was mangling keybinder.

pecan