Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

wxMathPlot as a dynamic Library

Help
pinchas
2008-12-22
2013-05-02
  • pinchas
    pinchas
    2008-12-22

    Hi all,

    I'm using wxWidget as a <b>dll</b>. Thus, I need to use wxMathPlot as dynamic library as well (I use Visual Studio 2003). To do that I run the cmake file and I point the wxWidget lib dir  to the wxWidgets dll folder. Then, under project properties->General I choose the configuration type to be dynamic library and under c/c++->preprocessor->Preprocessor definitions I put WXUSINGDLL (and all the rest as explained in http://wiki.wxwidgets.org/MSVC\). When compiling it, I got the following <b>error</b>
    :

    \wxmathplot-0.1.0\mathplot.cpp(343): error C2491: 'mpFX::ms_classInfo' : definition of dllimport static data member not allowed.

    Any idea is very welcome.

    Thanks in advance,

     
    • cdron77
      cdron77
      2008-12-24

      It's always in my TODO list to implement the choice between static and shared library for wxMathPlot. Up to now this remains in the wish list mainly because Windows DLL is a weird obscure world for me.

      Anyway, I'll to give you some hints. First of all, try modifying CMakeLists.txt file[1] instead of working with Visual Studio options: this is more clear and portable. The error you get[2] is probably generated because the class mpFX (but also the other classes) is declared using DECLARE_CLASS macro, instead of using DECLARE_DYNAMIC_CLASS [3].

      If you get some results, please let me know, so I'll can fix it in new releases.

      [1] http://www.vtk.org/Wiki/BuildingWinDLL
      [2] http://msdn.microsoft.com/en-us/library/62688esh\(VS.71).aspx
      [3] http://docs.wxwidgets.org/stable/wx_rttimacros.html#declaredynamicclass

       
    • Tosh Shigeoka
      Tosh Shigeoka
      2009-06-27

      Hi all

      I made a patch to create windows dll. It works at least on my pc (windows xp + MSVC++ 8 and ubuntu linux + gcc). I hope this patch works well in your pc.

      ----- patch start ----- 
      Index: trunk/mathplot/mathplot.h
      ===================================================================
      --- trunk/mathplot/mathplot.h    (リビジョン 61)
      +++ trunk/mathplot/mathplot.h    (作業コピー)
      @@ -47,6 +47,17 @@
           Jose Luis Blanco, Val Greene.<br>
      */

      +//this definition uses windows dll to export function.
      +//WXDLLEXPORT definition definition changed to WXDLLIMPEXP_MATHPLOT
      +//mathplot_EXPORTS will be defined by cmake
      +#ifdef mathplot_EXPORTS
      +    #define WXDLLIMPEXP_MATHPLOT                  WXEXPORT
      +    #define WXDLLIMPEXP_DATA_MATHPLOT(type)       WXEXPORT type
      +#else // not making DLL
      +    #define WXDLLIMPEXP_MATHPLOT
      +    #define WXDLLIMPEXP_DATA_MATHPLOT(type)        type
      +#endif
      +
      #if defined(__GNUG__) && !defined(__APPLE__)
      #pragma interface "mathplot.h"
      #endif
      @@ -76,16 +87,16 @@
      // classes
      //-----------------------------------------------------------------------------

      -class WXDLLEXPORT mpLayer;
      -class WXDLLEXPORT mpFX;
      -class WXDLLEXPORT mpFY;
      -class WXDLLEXPORT mpFXY;
      -class WXDLLEXPORT mpFXYVector;
      -class WXDLLEXPORT mpScaleX;
      -class WXDLLEXPORT mpScaleY;
      -class WXDLLEXPORT mpWindow;
      -class WXDLLEXPORT mpText;
      -class WXDLLEXPORT mpPrintout;
      +class WXDLLIMPEXP_MATHPLOT mpLayer;
      +class WXDLLIMPEXP_MATHPLOT mpFX;
      +class WXDLLIMPEXP_MATHPLOT mpFY;
      +class WXDLLIMPEXP_MATHPLOT mpFXY;
      +class WXDLLIMPEXP_MATHPLOT mpFXYVector;
      +class WXDLLIMPEXP_MATHPLOT mpScaleX;
      +class WXDLLIMPEXP_MATHPLOT mpScaleY;
      +class WXDLLIMPEXP_MATHPLOT mpWindow;
      +class WXDLLIMPEXP_MATHPLOT mpText;
      +class WXDLLIMPEXP_MATHPLOT mpPrintout;

      /** Command IDs used by mpWindow */
      enum
      @@ -120,7 +131,7 @@
            continuity set to false (draw separate points).
           These may or may not be used by implementations.
      */
      -class WXDLLEXPORT mpLayer : public wxObject
      +class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
      {
      public:
           mpLayer();
      @@ -297,7 +308,7 @@
           @brief Base class to create small rectangular info boxes
           mpInfoLayer is the base class to create a small rectangular info box in transparent overlay over plot layers. It is used to implement objects like legends.
      */
      -class WXDLLEXPORT mpInfoLayer : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpInfoLayer : public mpLayer
      {
      public:
           /** Default constructor. */
      @@ -364,7 +375,7 @@
      /** @class mpInfoCoords
           @brief Implements an overlay box which shows the mouse coordinates in plot units.
           When an mpInfoCoords layer is activated, when mouse is moved over the mpWindow, its coordinates (in mpWindow units, not pixels) are continuously reported inside the layer box. */
      -class WXDLLEXPORT mpInfoCoords : public mpInfoLayer
      +class WXDLLIMPEXP_MATHPLOT mpInfoCoords : public mpInfoLayer
      {
      public:
           /** Default constructor */
      @@ -395,7 +406,7 @@
      /** @class mpInfoLegend
           @brief Implements the legend to be added to the plot
           This layer allows to add a legend to describe the plots in the window. The legend uses the layer name as a label, and displays only layers of type mpLAYER_PLOT. */
      -class WXDLLEXPORT mpInfoLegend : public mpInfoLayer
      +class WXDLLIMPEXP_MATHPLOT mpInfoLegend : public mpInfoLayer
      {
      public:
           /** Default constructor */
      @@ -478,7 +489,7 @@
           Optionally implement a constructor and pass a name (label) and a label alignment
           to the constructor mpFX::mpFX. If the layer name is empty, no label will be plotted.
      */
      -class WXDLLEXPORT mpFX : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpFX : public mpLayer
      {
      public:
           /** @param name  Label
      @@ -510,7 +521,7 @@
           Optionally implement a constructor and pass a name (label) and a label alignment
           to the constructor mpFY::mpFY. If the layer name is empty, no label will be plotted.
      */
      -class WXDLLEXPORT mpFY : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpFY : public mpLayer
      {
      public:
           /** @param name  Label
      @@ -543,7 +554,7 @@
           Optionally implement a constructor and pass a name (label) and a label alignment
           to the constructor mpFXY::mpFXY. If the layer name is empty, no label will be plotted.
      */
      -class WXDLLEXPORT mpFXY : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpFXY : public mpLayer
      {
      public:
           /** @param name  Label
      @@ -581,7 +592,7 @@
           Optionally implement a constructor and pass a name (label) and a label alignment
           to the constructor mpProfile::mpProfile. If the layer name is empty, no label will be plotted.
      */
      -class WXDLLEXPORT mpProfile : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpProfile : public mpLayer
      {
      public:
           /** @param name  Label
      @@ -622,7 +633,7 @@
           the bottom-right hand of the ruler. The scale numbering automatically
           adjusts to view and zoom factor.
      */
      -class WXDLLEXPORT mpScaleX : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpScaleX : public mpLayer
      {
      public:
           /** @param name Label to plot by the ruler
      @@ -674,7 +685,7 @@
           the top-right hand of the ruler. The scale numbering automatically
           adjusts to view and zoom factor.
      */
      -class WXDLLEXPORT mpScaleY : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpScaleY : public mpLayer
      {
      public:
           /** @param name Label to plot by the ruler
      @@ -751,7 +762,7 @@
               - Mouse Wheel DOWN+CTRL: Zoom out

      */
      -class WXDLLEXPORT mpWindow : public wxScrolledWindow
      +class WXDLLIMPEXP_MATHPLOT mpWindow : public wxScrolledWindow
      {
      public:
           mpWindow() {}
      @@ -1167,7 +1178,7 @@

            (Added: Jose Luis Blanco, AGO-2007)
      */
      -class WXDLLEXPORT mpFXYVector : public mpFXY
      +class WXDLLIMPEXP_MATHPLOT mpFXYVector : public mpFXY
      {
      public:
           /** @param name  Label
      @@ -1242,7 +1253,7 @@
      on the plot reguardless of the other layers location and scaling
      factors.
      */
      -class WXDLLEXPORT mpText : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpText : public mpLayer
      {
      public:
           /** @param name text to be drawn in the plot
      @@ -1273,7 +1284,7 @@
           The object itself can then used by the default wxWidgets printing system
           to print mppWindow objects.
      */
      -class WXDLLEXPORT mpPrintout : public wxPrintout
      +class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
      {
      public:
           mpPrintout(mpWindow* drawWindow, const wxChar *title = _T("wxMathPlot print output"));
      @@ -1298,7 +1309,7 @@
         *  be in charge of Bounding Box computation and layer render, assuming that
         *  the object updates its shape in m_shape_xs & m_shape_ys.
         */
      -class WXDLLEXPORT mpMovableObject : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpMovableObject : public mpLayer
      {
      public:
           /** Default constructor (sets location and rotation to (0,0,0))
      @@ -1406,7 +1417,7 @@
         *
         * The ellipse will be always centred at the origin. Use mpMovableObject::SetCoordinateBase to move it.
         */
      -class WXDLLEXPORT mpCovarianceEllipse : public mpMovableObject
      +class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse : public mpMovableObject
      {
      public:
           /** Default constructor.
      @@ -1487,7 +1498,7 @@
         *  Use "setPoints" to set the list of N points. This class also can draw non-closed polygons by
         *   passing the appropriate parameters to "setPoints". To draw a point-cloud, call "SetContinuity(false)".
         */
      -class WXDLLEXPORT mpPolygon : public mpMovableObject
      +class WXDLLIMPEXP_MATHPLOT mpPolygon : public mpMovableObject
      {
      public:
           /** Default constructor.
      @@ -1523,7 +1534,7 @@
         *  be in charge of Bounding Box computation and layer render, assuming that
         *  the object updates its shape in m_shape_xs & m_shape_ys.
         */
      -class WXDLLEXPORT mpBitmapLayer : public mpLayer
      +class WXDLLIMPEXP_MATHPLOT mpBitmapLayer : public mpLayer
      {
      public:
           /** Default constructor.

      ----- patch end -----

       
    • Jack Dodds
      Jack Dodds
      2009-07-29

      Hello Tosh Shigeoka,

      I'd like to try your patch to make wxMathPlot a dll.  I have tried to compile is as a static library and have had problems.  However when I try to apply your patch, this is what happens:

      C:\Documents and Settings\jack.dodds\My Documents\_Projects\MathPlot>patch mathp
      lot.h dllpatch.txt
      patching file mathplot.h
      patch: **** malformed patch at line 6: Jose Luis Blanco, Val Greene.<br>

      The above was done with a Windows version of patch, but I also tried using the patch distributed with Cygwin, with exactly the same result.  also I tried deleting the first section of the patch.  Then I got the same message on the second section.  I made the dllpatch.txt file by cutting from your post in this thread and pasting into Notebook.  Perhaps there are some unprintable characters that make the patch program choke.

      Could you possibly email me a copy of your diff file (as an attachment) at jack@geotech.ca so I can try with a file that I know is unchnaged from the one that you are using?

      Thanks

      Jack Dodds

       
      • cdron77
        cdron77
        2009-07-30

        The patch has been already integrated into the wxMathPlot SVN trunk, so you can checkout the latest code from repository to get the patched code, plus some other improvementent (scrollbars working again and other bugfixes).

         
    • Jack Dodds
      Jack Dodds
      2009-07-31

      Thanks for the above.

      I figured out that the patch in zundoya's post doesn't work because the "context" lines are not preceded by a <space> character.