12 Replies Latest reply on Dec 22, 2015 9:46 AM by Galileo_BR

    Galileo error: 'square' was not declared in this scope [Library]

    Galileo_BR

      Hello ! Added a library Galileo IDE (1.6.0), AcceleroMMA7361.h basic procedure .. Sketch> Import Library> Add Library .. but this does not compile, I get the following failure:

       

       

      C: \ Users \ Antonio \ Documents \ Arduino \ libraries \ AcceleroMMA7361 \ AcceleroMMA7361.cpp: 406: 44: error: 'square' was not declared in this scope

      Compiling error.

       

       

      But if I switch Tools> board> Arduino Uno, the sample code using the library of 7361 is successfully compiled.

       

       

      This failure happens to every library that are added to Galileo IDE.

      Any solution for this? Thank you !

       

       

       

       

      Galileo IDE 1.6.0

      Windows 7-64bits

        • 1. Re: Galileo error: 'square' was not declared in this scope [Library]
          FGT

          Hi,

           

          I've not used 7361 at all, but please try this;

           

          a) Copy every .h and .cpp in the same directory where you have the sketch

          b) use #include "..." instead of #incude <...>

          c) Compile

           

          Please use the minimum sketch so we can isolate the problem in less time (hopefully).

           

          HTH,

           

          Fernando.

          • 2. Re: Galileo error: 'square' was not declared in this scope [Library]
            Galileo_BR

            Hello !

            The library files 7361 .h and .cpp are in the same directory, used "..." as said, but it gives the same error.

            I am testing an example of the library itself, which worked on Arduino, but does not compile in galileoIDE. (Remember that the code compiles in the same IDE 1.6.0, just select the card, Arduino Uno or GalileoGen2).

             

            Below is the sample tested on Galileo IDE.

             

            #include "AcceleroMMA7361.h" 

            AcceleroMMA7361 accelero;

            int x;

            int y;

            int z;

            void setup()

            {

              Serial.begin(9600);

              accelero.begin(13, 12, 11, 10, A0, A1, A2);

              accelero.setARefVoltage(3.3); //sets the AREF voltage to 3.3V

              accelero.setSensitivity(LOW); //sets the sensitivity to +/-6G

              accelero.calibrate(); 

            }

            void loop()

            {

              x = accelero.getXVolt();

              y = accelero.getYVolt();

              z = accelero.getZVolt();

              Serial.print("\nx: ");

              Serial.print(x); 

              Serial.print("mV\ty: ");

              Serial.print(y); 

              Serial.print("mV\tz: ");

              Serial.print(z);

              Serial.print("mV");

              delay(500); //make it readable

            }


            error:

            C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp: In member function 'void AcceleroMMA7361::setARefVoltage(double)':

            C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp:111:19: error: 'EXTERNAL' was not declared in this scope

            C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp: In member function 'int AcceleroMMA7361::getTotalVector()':

            C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp:406:44: error: 'square' was not declared in this scope

            Erro compilando

             

            Detail the example of "Simple Audio Player" using "Audio.h" also made the same mistake, but has already come loaded on Galileo IDE.

            I have not added.

            There seems to be some incompatibility between avr and x86 I can not explain.

             

            Thanks for help!

             

            EDIT:

             

            All research points to a direction in which most of the libraries have not been ported to Quark, which indicates the need to be 'rewritten'.

            Could test the library and report it gives the same error described above ?

            • 3. Re: Galileo error: 'square' was not declared in this scope [Library]
              FGT

              I think there are several "details"...

               

              The error indicated by

              error:

              C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp: In member function 'void AcceleroMMA7361::setARefVoltage(double)':

              C:\arduino-1.6.0+Intel\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp:111:19: error: 'EXTERNAL' was not declared in this scope

               

              should not be there, I think, given that the use of 'EXTERNAL' seems to be legal as defined at Arduino - AnalogReference

               

              The use of "square" (which seems to be a function to have the square number of the parameter...) is not so direct... where did you get the code from?

               

              Fernando.

              • 4. Re: Galileo error: 'square' was not declared in this scope [Library]
                Galileo_BR

                This code comes as an example (there are three in all) this library of 7361.

                 

                7361problem.png

                7361problem2.png

                7361problem3.png



                Note that selecting Arduino Uno below, the code is compiled.

                7361problem4.png

                7361problem5.png

                 

                This example "Voltage" prints the serial monitor the values of X, Y, Z, in milli volts.

                Changing of 1400mV to 1800mV each axis.

                • 5. Re: Galileo error: 'square' was not declared in this scope [Library]
                  FGT

                  Galileo_BR wrote:

                   

                  This code comes as an example (there are three in all) this library of 7361.

                   

                  I didn't ask correctly: where did you get the library code from?

                   

                  Anyhow, I'm pretty sure there is some Galileo bug here or, at least you are right in both:

                     "There seems to be some incompatibility between avr and x86 I can not explain."

                     "All research points to a direction in which most of the libraries have not been ported to Quark, which indicates the need to be 'rewritten'."

                   

                  Fernando.

                  • 6. Re: Galileo error: 'square' was not declared in this scope [Library]
                    Galileo_BR

                    I do not recall where there were downloaded, Anyway I will download another on GitHub, I will replace it, and test again, post here in any case the result.

                     

                     

                    continuing:

                     

                     

                    I installed the downloadable library at GitHub, but was generated another error to GalileoGen2 board. https://github.com/jeroendoggen/Arduino-MMA7361-library

                     

                    C:\Users\Antonio\Documents\Arduino\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp:115:21: error: 'EXTERNAL' was not declared in this scope

                    C:\Users\Antonio\Documents\Arduino\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp: In member function 'int AcceleroMMA7361::getTotalVector()':

                    C:\Users\Antonio\Documents\Arduino\libraries\AcceleroMMA7361\AcceleroMMA7361.cpp:372:45: error: 'square' was not declared in this scope

                     

                     

                    Compiling for Arduino runs well. no problem.

                    To see inside the library noticed it's a little different from the last, even so, I'm beginning to believe that there is really no solution because they were written for avr architecture.

                    It forces me to two options, a dedicated write the most basic functions code without the need for library use, or study more in order to use it .. if someone does not have a magic solution hehe.

                    • 7. Re: Galileo error: 'square' was not declared in this scope [Library]
                      DiegoV_Intel

                      Hello Galileo_BR,

                       

                      The error related to the EXTERNAL ADC mode is due to the fact that Galileo, besides the default mode, doesn't have another mode to configure the ADC reference. Check the code below, it is the source code for the analogReference() function on Galileo:

                       

                      void analogReference(uint8_t mode)
                      {
                      /* Retained for backward compatibilty, only DEFAULT is supported */
                      }
                      

                       

                      You can edit the code where the library tries to configure the ADC reference to avoid that error.

                       

                      Regarding the error related to the square() function. It is because the function is not declared, and the library tries to use it. You can write the square() function easily since it only calculates the square value of a number: nxn

                       

                      Regards,

                      Diego.

                      • 8. Re: Galileo error: 'square' was not declared in this scope [Library]
                        Galileo_BR

                        Hello Diego!

                        The function 'square ()' seems to have settled now left the following error:



                        mmaCPP-External2.png

                         

                        mmaCPP-External.png

                        Above I should then eliminate the '.cpp' library everything related to _refVoltage and analogReference? and also library '.h'

                         

                        AREFgalileo.png

                        GalileoGen2 that does not use pin according to scheme.

                         

                        Thanks!

                        • 9. Re: Galileo error: 'square' was not declared in this scope [Library]
                          DiegoV_Intel

                          If you are not going to use the functions where the analogReference() is called, then you could comment the lines. For example, if the function setARefVoltage() is not used anywhere in the main code, then comment the entire function. I recommend you to comment the lines instead of deleting them.

                           

                          I believe you can keep the .h file without any change. Usually, the .h files only include definitions that are used in the .cpp files. The .cpp files, on the other hand, contain the full code.

                           

                          Regards,

                          Diego.

                          • 10. Re: Galileo error: 'square' was not declared in this scope [Library]
                            Galileo_BR

                            Comment multiple lines in the cpp file, and finally compiled \o/

                            However, due to lack of analog references, Galileo did not print any one type of reading (miliVolts) in the serial monitor

                             

                            mmaGalileo-OK.png

                             

                            Below is the link that needs to work with Arduino MMA7361

                             

                            ArduinoAnalogRef.png

                             

                            Would have some way of generating a reference Analog physically Galileo or just modifying final code?

                            (I used the example Voltage.ino posted well above)

                            • 11. Re: Galileo error: 'square' was not declared in this scope [Library]
                              DiegoV_Intel

                              Hello Galileo_BR,

                               

                              The only analogue reference used by Galileo is the default value: 5V, so there is no way to set an external analogue reference for the ADC.

                               

                              Regards,

                              Diego.