MySensors library 1.4 fails to compile when run on RPi (solved)



  • Hey,

    I am new with the MySensors library, and I just installed it on my Raspberry Pi, where I have the Arduino framework (1.0.1) as well. I was going to try out some of the examples using the Arduino IDE, but for some reason it seems that the library fails to compile when I try to verify the code. When running for example the BatteryPoweredSensor example the compiling fails to the following error:

    avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=8000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/SPI -I/home/pi/sketchbook/libraries/MySensors /tmp/build469947204035938533.tmp/BatteryPoweredSensor.cpp -o /tmp/build469947204035938533.tmp/BatteryPoweredSensor.cpp.o 
    BatteryPoweredSensor.cpp: In function ‘void loop()’:
    BatteryPoweredSensor.cpp:30:8: warning: unused variable ‘sensorValue’ [-Wunused-variable]
      Using previously compiled: /tmp/build469947204035938533.tmp/SPI/SPI.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/MyMessage.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/MySensor.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/MyGateway.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/MyMQTT.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/utility/LowPower.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/utility/MsTimer2.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/MySensors/utility/RF24.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/wiring_analog.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/wiring_pulse.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/wiring_digital.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/wiring_shift.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/wiring.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/WInterrupts.c.o
      Using previously compiled: /tmp/build469947204035938533.tmp/HardwareSerial.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/USBCore.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/Stream.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/main.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/HID.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/WString.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/WMath.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/IPAddress.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/new.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/Print.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/Tone.cpp.o
      Using previously compiled: /tmp/build469947204035938533.tmp/CDC.cpp.o
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/wiring_analog.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/wiring_pulse.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/wiring_digital.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/wiring_shift.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/wiring.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/WInterrupts.c.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/HardwareSerial.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/USBCore.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/Stream.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/main.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/HID.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/WString.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/WMath.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/IPAddress.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/new.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/Print.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/Tone.cpp.o 
    avr-ar rcs /tmp/build469947204035938533.tmp/core.a /tmp/build469947204035938533.tmp/CDC.cpp.o 
    avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build469947204035938533.tmp/BatteryPoweredSensor.cpp.elf /tmp/build469947204035938533.tmp/BatteryPoweredSensor.cpp.o /tmp/build469947204035938533.tmp/SPI/SPI.cpp.o /tmp/build469947204035938533.tmp/MySensors/MyMessage.cpp.o /tmp/build469947204035938533.tmp/MySensors/MySensor.cpp.o /tmp/build469947204035938533.tmp/MySensors/MyGateway.cpp.o /tmp/build469947204035938533.tmp/MySensors/MyMQTT.cpp.o /tmp/build469947204035938533.tmp/MySensors/utility/LowPower.cpp.o /tmp/build469947204035938533.tmp/MySensors/utility/MsTimer2.cpp.o /tmp/build469947204035938533.tmp/MySensors/utility/RF24.cpp.o /tmp/build469947204035938533.tmp/core.a -L/tmp/build469947204035938533.tmp -lm 
    MySensors/MySensor.cpp.o: In function `MySensor::freeRam()':
    /home/pi/sketchbook/libraries/MySensors/MySensor.cpp:586: undefined reference to `operator new[](unsigned int)'
    collect2: error: ld returned 1 exit status
    

    I simplified the source to see if it's a specific call that would cause the issues, but it doesn't seem that way. The source that I am using is pasted under.

    // This is an example that demonstrates how to report the battery level for a sensor
    // Instructions for measuring battery capacity on A0 are available in the follwoing forum
    // thread: http://forum.micasaverde.com/index.php/topic,20078.0.html
    
    #include <SPI.h>
    #include <MySensor.h>
    
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    
    MySensor gw;
    unsigned long SLEEP_TIME = 900000;  // sleep time between reads (seconds * 1000 milliseconds)
    int oldBatteryPcnt = 0;
    
    void setup()  
    {
       // use the 1.1 V internal reference
       analogReference(INTERNAL);
       gw.begin();
    
       // Send the sketch version information to the gateway and Controller
       gw.sendSketchInfo("Battery Meter", "1.0");
    }
    
    void loop()
    {
       // get the battery Voltage
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       gw.sleep(SLEEP_TIME);
    }
    

    Anyone have any ideas how to get the library working?



  • Alright,

    I figured it out. It was no more complicated than updating the Arduino IDE and the avr-gcc compiler from the outdated versions (Arduino IDE 1.0.1) automatically installed by the apt-get.

    The instructions for updating the Arduino IDE and the compilers can be found here: https://nicohood.wordpress.com/2015/01/24/installing-avr-gcc-4-8-1-and-arduino-ide-1-6-on-raspberry-pi/


Log in to reply
 

Suggested Topics

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts