Monday, 15 August 2011

wxwidgets - Failed to create shared library with wx and STL, "multiple definition" error? -


I tried to create a shared library using wx and STL, and failed in an error of "multiple definition" Please see:

  • wxPointListNode is not found in sources. The suspicious lines are like this:

      include / mathplot.h: 85: WX_DECLARE_LIST (wxPoint, PointList); 87 :: / mathplot.h included WX_DEFINE_LIST (PointList); Include / gpLineLayer.h: 16: typed Spread :: Deck & lt; MpPointLayer * & gt; MpPointList_t;   

    What's the problem?

    All wxWidgets methods define spreads in the definition of something in their name And a definition can be used only once in a module, so it can not usually appear in a header file (unless you can guarantee that this is only a single source file). So just do not put it.

    In addition, if this is your code, you should avoid using the legacy WX_DECLARE_LIST macro and simply std :: list & lt; & Gt; or std :: vector & lt; & Gt; Or instead, if you really want to use only wx (which can be important only if you are targeting some embedded platforms without some SBT implementation), then wxVector & lt ; & Gt; Use .

    No comments:

    Post a Comment