I can't compile.

Help
2007-08-29
2013-04-26
  • Manuel Carlevaro

    Hello.

    I am trying to install Extrema 4.2.7 in a AMD64 machine with Debian GNU/Linux.

    The first problem was the absence of "#include <math.h>" in the Command.h file, so I added that line.

    Then, during the compilation, the following errors appear:

    CMD_get.cpp:85: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
    /usr/include/wx/string.h:429: note: candidate 1: wxChar wxString::operator[](int) const
    /usr/include/wx/string.h:442: note: candidate 2: wxChar& wxString::operator[](unsigned int)
    CMD_get.cpp:85: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
    /usr/include/wx/string.h:429: note: candidate 1: wxChar wxString::operator[](int) const
    /usr/include/wx/string.h:433: note: candidate 2: wxChar& wxString::operator[](size_t)
    CMD_get.cpp:110: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
    /usr/include/wx/string.h:429: note: candidate 1: wxChar wxString::operator[](int) const
    /usr/include/wx/string.h:442: note: candidate 2: wxChar& wxString::operator[](unsigned int)
    CMD_get.cpp:110: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
    /usr/include/wx/string.h:429: note: candidate 1: wxChar wxString::operator[](int) const
    /usr/include/wx/string.h:433: note: candidate 2: wxChar& wxString::operator[](size_t)
    make[2]: *** [CMD_get.lo] Error 1

    I can't figure out how to solve it. Can you give some advice for fix it?

    Thank you in advance.

    Manuel.

     
    • Joe Chuma

      Joe Chuma - 2007-09-10

      Sorry for the long delay in answering.  I have been away on holiday.

      Someone else has been having similar problems compiling extrema using gcc 4.1.2.

      The first problem is missing math.h includes.  This is fixed by adding

      #include <cmath>

      at the top of the files mentioned in the compiler messages.  I believe you should use cmath instead of math.h, since this is C++.  Why the newer compiler complains about this when the older compilers don't is a mystery.

      The other problem seems to occur when referencing an element of a wxString using the [] operator.  There should be no difference between using the [] operator and using the at() function.  So, the fix for this is to replace [] with at() wherever the compiler complains.  For example, on line 85 of CMD_get.cpp, replace "line[0]" with "line.at(0)".

      I will add the "#include <cmath>" lines to the problem source files that I am aware of (so far Command.h, CMD_bestfit.cpp, CMD_ellipse.cpp) and replace [] with at() in the files CMD_get.cpp and CMD_read.cpp

      Thanks for the bug report, and hopefully the problems will be fixed in the next release.

      Joe Chuma

       
    • Manuel Carlevaro

      Hello Joe,

      Thank you for your answer. I'm still trying to compile Extrema. Following your indications, I include <cmath> in Command.h, FCN_adev.h, FCN_mean.h, FCN_gmean.h, FCN_rms.h, FCN_skew.h and FCN_stdev.h. I also changed "[*]" by ".at(*)" in CMD_get.cpp, CMD_read.cpp, CMD_scalar.cpp, CMD_set.cpp, Command.cpp, FCN_date.cpp, FCN_time.cpp and FCN_axis.cpp in every line informed by the compiler.

      Now, I'm trapped in other compilation error:

      GRA_axis.cpp: In member function 'void GRA_axis::MakeAxisLabel()':
      GRA_axis.cpp:207: error: 'label. wxString::operator+=(((const wxString&)((const wxString*)(& operator+(const wxString&, const wxString&)(((const wxString&)((const wxString*)(& powLabel))))))))' has type 'void' and is not a throw-expression
      make[2]: *** [GRA_axis.lo] Error 1

      I will really appreciate if you can help me solving this error.

      Manu-x.

       
    • Joe Chuma

      Joe Chuma - 2007-09-11

      Thank you for going to all that work.  I will modify my sources to include the changes you have made, so hopefully no one will have to do that again.

      For the next error, try replacing line 207 in GRA_axis.cpp

          label.empty() ? label=powLabel : label+=wxString(wxT(" "))+powLabel;

      with

          label.empty() ? label=powLabel : label << wxT(" ") << powLabel;

      Why the newer compiler doesn't like the += operator above, I have no idea, but it accepts the inserter operator used in the same code, so maybe this will work.

      Joe Chuma

       
    • Manuel Carlevaro

      Hello Joe,

      Your previous correction did it well, now I get another error during compilation:

      g++ -DPACKAGE_NAME=\&quot;extrema\&quot; -DPACKAGE_TARNAME=\&quot;extrema\&quot; -DPACKAGE_VERSION=\&quot;4.2.7\&quot; "-DPACKAGE_STRING=\&quot;extrema 4.2.7\&quot;" "-DPACKAGE_BUGREPORT=\&quot;Joseph L. Chuma chuma@triumf.ca\&quot;" -DPACKAGE=\&quot;extrema\&quot; -DVERSION=\&quot;4.2.7\&quot; -DHAVE_DLFCN_H=1 -I. -I. -I../../src -I../../src/Commands -I../../src/Expression -I../../src/Functions -I../../src/Graphics -I../../src/Operators -I../../src/Parsing -I../../src/Utilities -I../../src/Variables -I../../src/wxForms -I/usr/include/libxml2 -DEX_DATADIR=\&quot;/usr/local/share\&quot; -DEX_BINDIR=\&quot;/usr/local/bin\&quot; -I/usr/lib/wx/include/gtk-2.4 -DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -g -O2 -MT GRA_cartesianCurve.lo -MD -MP -MF .deps/GRA_cartesianCurve.Tpo -c GRA_cartesianCurve.cpp -o GRA_cartesianCurve.o
      ../../src/wxForms/ExSpinCtrlD.h: In constructor 'ExSpinCtrlD<T>::ExSpinCtrlD(wxPanel*, const wxString&, T*, void (T::*)(double))':
      ../../src/wxForms/ExSpinCtrlD.h:35: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlD.h:35: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
      ../../src/wxForms/ExSpinCtrlD.h:40: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlD.h:43: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlD.h:47: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlI.h: In constructor 'ExSpinCtrlI<T>::ExSpinCtrlI(wxPanel*, const wxString&, int, int, T*, void (T::*)(int))':
      ../../src/wxForms/ExSpinCtrlI.h:36: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlI.h:41: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlI.h:44: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExSpinCtrlI.h:48: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExColorCtrl.h: In constructor 'ExColorCtrl<T>::ExColorCtrl(wxPanel*, const wxString&, T*, void (T::*)(GRA_color*))':
      ../../src/wxForms/ExColorCtrl.h:37: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      ../../src/wxForms/ExColorCtrl.h:39: error: there are no arguments to 'wxSizerFlags' that depend on a template parameter, so a declaration of 'wxSizerFlags' must be available
      make[2]: *** [GRA_cartesianCurve.lo] Error 1
      make[2]: se sale del directorio `/home/manuel/tools/extrema-4.2.7/src/Graphics'
      make[1]: *** [all-recursive] Error 1

      It seems to be a long way to the compilation success... ;-)

      If you agree, I can send you the modified files.

      Manu-x.

       
    • Joe Chuma

      Joe Chuma - 2007-09-12

      This new compiler is certainly causing a lot of problems.  I had no idea that my code was so non-compliant...

      Anyway, could you try adding the following line

      #include "wx/sizer.h"

      after the line

      #include "wx/wx.h"

      in the files: ExSpinCtrlD.h, ExSpinCtrlI.h, and ExColorCtrl.h

      Then, in those same files, declare an instance of wxSizerFlags with:

            wxSizerFlags flags(0);

      Add this line right after the line

            SetSizer( sizer );

      Then below that replace all instances of "wxSizerFlags(0)" with "flags".
      This change is somewhat more complicated that the previous ones, and I hope that is the last problem.

      I have corrected my source code with all the changes so far, but if you would like to send me your modified code, I could confirm that I have made all the necessary changes.

      Joe Chuma

       
      • Manuel Carlevaro

        Unfortunately, your last correction didn't work. Perhaps I am doing something wrong.

        After the last changes, I get the following errors:

        g++ -DPACKAGE_NAME=\&quot;extrema\&quot; -DPACKAGE_TARNAME=\&quot;extrema\&quot; -DPACKAGE_VERSION=\&quot;4.2.7\&quot; "-DPACKAGE_STRING=\&quot;extrema 4.2.7\&quot;" "-DPACKAGE_BUGREPORT=\&quot;Joseph L. Chuma chuma@triumf.ca\&quot;" -DPACKAGE=\&quot;extrema\&quot; -DVERSION=\&quot;4.2.7\&quot; -DHAVE_DLFCN_H=1 -I. -I. -I../../src -I../../src/Commands -I../../src/Expression -I../../src/Functions -I../../src/Graphics -I../../src/Operators -I../../src/Parsing -I../../src/Utilities -I../../src/Variables -I../../src/wxForms -I/usr/include/libxml2 -DEX_DATADIR=\&quot;/usr/local/share\&quot; -DEX_BINDIR=\&quot;/usr/local/bin\&quot; -I/usr/lib/wx/include/gtk-2.4 -DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -g -O2 -MT GRA_cartesianCurve.lo -MD -MP -MF .deps/GRA_cartesianCurve.Tpo -c GRA_cartesianCurve.cpp -o GRA_cartesianCurve.o
        ../../src/wxForms/ExSpinCtrlD.h: In constructor 'ExSpinCtrlD<T>::ExSpinCtrlD(wxPanel*, const wxString&, T*, void (T::*)(double))':
        ../../src/wxForms/ExSpinCtrlD.h:35: error: 'wxSizerFlags' was not declared in this scope
        ../../src/wxForms/ExSpinCtrlD.h:35: error: expected `;' before 'flags'
        ../../src/wxForms/ExSpinCtrlD.h:37: error: 'flags' was not declared in this scope
        ../../src/wxForms/ExSpinCtrlI.h: In constructor 'ExSpinCtrlI<T>::ExSpinCtrlI(wxPanel*, const wxString&, int, int, T*, void (T::*)(int))':
        ../../src/wxForms/ExSpinCtrlI.h:36: error: 'wxSizerFlags' was not declared in this scope
        ../../src/wxForms/ExSpinCtrlI.h:36: error: expected `;' before 'flags'
        ../../src/wxForms/ExSpinCtrlI.h:38: error: 'flags' was not declared in this scope
        ../../src/wxForms/ExColorCtrl.h: In constructor 'ExColorCtrl<T>::ExColorCtrl(wxPanel*, const wxString&, T*, void (T::*)(GRA_color*))':
        ../../src/wxForms/ExColorCtrl.h:38: error: 'wxSizerFlags' was not declared in this scope
        ../../src/wxForms/ExColorCtrl.h:38: error: expected `;' before 'flags'
        ../../src/wxForms/ExColorCtrl.h:39: error: 'flags' was not declared in this scope
        make[2]: *** [GRA_cartesianCurve.lo] Error 1

        I think that I carried out the changes correctly, but I'm pasting the code of ExSpinCtrlD.h so you can check it out:
        ---------------------------------------------------------------------------------
        /*
        Copyright (C) 2007 Joseph L. Chuma, TRIUMF

        This program is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License
        as published by the Free Software Foundation; either version 2
        of the License, or (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
        */
        #ifndef EXTREMA_SPINCTRLD
        #define EXTREMA_SPINCTRLD

        #include "wx/wx.h"
        #include "wx/sizer.h"
        #include "wx/spinbutt.h"
        #include "wx/textctrl.h"

        template<typename T>
        class ExSpinCtrlD : public wxPanel
        {
        public:
          ExSpinCtrlD( wxPanel *parent, wxString const &label, T *popup, void (T::*memFunc)(double) )
              : wxPanel(parent), popup_(popup), memFunc_(memFunc)
          {
            wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
            SetSizer( sizer );
            wxSizerFlags flags(0);
           
            sizer->Add( new wxStaticText(this,wxID_ANY,label), flags.Left().Border(wxALL,2) );
           
            wxPanel *panel2 = new wxPanel( this );
            wxBoxSizer *sizer2 = new wxBoxSizer( wxHORIZONTAL );
            panel2->SetSizer( sizer2 );
            sizer->Add( panel2, flags.Center().Border(wxALL,1) );
           
            textCtrl_ = new wxTextCtrl( panel2, ID_text );
            sizer2->Add( textCtrl_, flags.Left().Border(wxALL,1) );
           
            spinButton_ = new wxSpinButton( panel2, ID_spin );
            spinButton_->SetRange( 0, 1000 );
            sizer2->Add( spinButton_, flags.Left().Border(wxALL,1) );
           
            Connect( ID_spin, wxID_ANY, wxEVT_SCROLL_THUMBTRACK,
                     (wxObjectEventFunction)
                     (wxEventFunction)
                     (wxCommandEventFunction)&ExSpinCtrlD<T>::OnSpinChange );
           
            Connect( ID_text, wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED,
                     (wxObjectEventFunction)
                     (wxEventFunction)
                     (wxCommandEventFunction)&ExSpinCtrlD<T>::OnTextChange );
          }

          void SetValue( double val )
          {
            int itmp = static_cast<int>(val*10+0.5);
            spinButton_->SetValue( itmp );
            textCtrl_->SetValue( wxString()<<itmp/10. );
          }

        private:
          void OnSpinChange( wxSpinEvent &WXUNUSED(event) )
          {
            double val = 0.1*spinButton_->GetValue();
            textCtrl_->SetValue( wxString()<<val );
            (popup_->*memFunc_)( val );
          }
         
          void OnTextChange( wxCommandEvent &WXUNUSED(event) )
          {
            wxString text( textCtrl_->GetValue() );
            if( text.empty() )return;
            double val;
            if( !text.ToDouble(&val) || val<0.0 || val>100.0 )
            {
              wxMessageDialog *md = new wxMessageDialog( this, wxT("invalid value entered"),
                                                         wxT("Error"), wxOK|wxICON_ERROR );
              md->ShowModal();
              return;
            }
            (popup_->*memFunc_)( val );
          }

          wxSpinButton *spinButton_;
          wxTextCtrl *textCtrl_;

          T *popup_;
          void (T::* memFunc_)(double);

          enum {
              ID_spin,
              ID_text
          };
         
          //DECLARE_EVENT_TABLE()
        };

        #endif
        ---------------------------------------------------------------------------------

        Regards,

        Manuel.

         
    • Joe Chuma

      Joe Chuma - 2007-09-12

      I really have to thank you for doing all this work for extrema.  I hope, when you get extrema up and running, it is worth the effort.

      It looks like my suggestion, unfortunately, wasn't enough.  My next suggestion is to again modify those same three files: ExSpinCtrlD.h, ExSpinCtrlI.h, and ExColorCtrl.h
      It seems to not like the wxSizerFlags class for some reason, so let's use the older sizer methods instead...

      In ExSpinCtrlD.h, replace the current constructor with this one

      ExSpinCtrlD( wxPanel *parent, wxString const &label, T *popup, void (T::*memFunc)(double) )
         : wxPanel(parent), popup_(popup), memFunc_(memFunc)
      {
        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
        SetSizer( sizer );
        sizer->Add( new wxStaticText(this,wxID_ANY,label), 0,wxALIGN_LEFT|wxALL,2 );
        wxPanel *panel2 = new wxPanel( this );
        wxBoxSizer *sizer2 = new wxBoxSizer( wxHORIZONTAL );
        panel2->SetSizer( sizer2 );
        sizer->Add( panel2, 0,wxALIGN_CENTER|wxALL,1 );
        textCtrl_ = new wxTextCtrl( panel2, ID_text );
        sizer2->Add( textCtrl_, 0,wxALIGN_LEFT|wxALL,1 );
        spinButton_ = new wxSpinButton( panel2, ID_spin );
        spinButton_->SetRange( 0, 1000 );
        sizer2->Add( spinButton_, 0,wxALIGN_LEFT|wxALL,1 );
        Connect( ID_spin, wxID_ANY, wxEVT_SCROLL_THUMBTRACK,
                   (wxObjectEventFunction)
                   (wxEventFunction)
                   (wxCommandEventFunction)&ExSpinCtrlD<T>::OnSpinChange );
        Connect( ID_text, wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED,
                   (wxObjectEventFunction)
                   (wxEventFunction)
                   (wxCommandEventFunction)&ExSpinCtrlD<T>::OnTextChange );
      }

      In ExSpinCtrlI.h, use this constructor:

        ExSpinCtrlI( wxPanel *parent, wxString const &label, int min, int max,
                     T *popup, void (T::*memFunc)(int) )
            : wxPanel(parent), popup_(popup), memFunc_(memFunc)
        {
          wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
          SetSizer( sizer );
          sizer->Add( new wxStaticText(this,wxID_ANY,label), 0,wxALIGN_LEFT|wxALL,2 );
          wxPanel *panel2 = new wxPanel( this );
          wxBoxSizer *sizer2 = new wxBoxSizer( wxHORIZONTAL );
          panel2->SetSizer( sizer2 );
          sizer->Add( panel2, 0,wxALIGN_CENTER|wxALL,2 );
          textCtrl_ = new wxTextCtrl( panel2, ID_text );
          sizer2->Add( textCtrl_, 0,wxALIGN_LEFT|wxALL,1 );
          spinButton_ = new wxSpinButton( panel2, ID_spin );
          spinButton_->SetRange( min, max );
          sizer2->Add( spinButton_, 0,wxALIGN_LEFT|wxALL,1 );
          Connect( ID_spin, wxID_ANY, wxEVT_SCROLL_THUMBTRACK,
                   (wxObjectEventFunction)
                   (wxEventFunction)
                   (wxCommandEventFunction)&ExSpinCtrlI<T>::OnSpinChange );
         
          Connect( ID_text, wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED,
                   (wxObjectEventFunction)
                   (wxEventFunction)
                   (wxCommandEventFunction)&ExSpinCtrlI<T>::OnTextChange );
        }

      and in ExColorCtrl.h use:

        ExColorCtrl( wxPanel *parent, wxString const &title, T *popup, void (T::*memFunc)(GRA_color *) )
            : wxPanel(parent), popup_(popup), memFunc_(memFunc)
        {
          wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
          SetSizer( sizer );
          sizer->Add( new wxStaticText(this,wxID_ANY,title), 0,wxALIGN_CENTER|wxALL,2 );
          button_ = new wxButton( this, ID_button, wxT(""), wxDefaultPosition, wxSize(25,25), wxRAISED_BORDER );
          sizer->Add( button_, 0,wxALIGN_CENTER|wxALL,1 );
          Connect( ID_button, wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,
                   (wxObjectEventFunction)
                   (wxEventFunction)
                   (wxCommandEventFunction)&ExColorCtrl<T>::OnClick );
        }

      This had better work, because I am running out of ideas.

      Joe Chuma

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks