Compilation blowing up on Debian w/arduino-013

The following program:

/* *
   NAME:                 MIDI Volume Foot Pedal Controller 
   E:                 9/9/2008
   FILE SAVED AS:        midi_volume.pde
   FOR:                  Miduino ATmega168
   CLOCK:                16.00 MHz CRYSTAL                                        
   PROGRAMME FUNCTION:   To read analogue potentiometer input and 
   output MIDI Volume control data.
 
**/


#define VOLUME_PIN 0
#define SWITCH_PIN 2
#define SWITCH_INT 0 // pin 2 is int 0
#define LED_PIN  13

#define VOLUME_CTRL 0x7
#define MODWHEEL_CTRL 0x1
#define CONTROLLER_CMD 0xB0


//variables setup

byte midiByte;
byte MIDIchannel = 0;
volatile byte volume_now=0;
volatile byte volume_past=0;
byte x;
volatile byte modwheel_toggle=LOW;
volatile byte prev_digital_state=HIGH;
volatile byte current_digital_state=HIGH;
volatile byte send_modwheel = 0;

#define DEBOUNCE_TIME 25        /* time to wait while "de-bouncing" button */
#define LOCK_INPUT_TIME 250     /* time to wait after a button press */


//_____________________________________________________________________________________________________

// Functions:


// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
    digitalWrite(LED_PIN,HIGH);  // indicate we're sending MIDI data
    Serial.print(cmd, BYTE);
    Serial.print(data1, BYTE);
    Serial.print(data2, BYTE);
    digitalWrite(LED_PIN,LOW);
}


void midi_volume(byte channel, byte vol) {
    midiMsg(CONTROLLER_CMD | (channel & 0xF), 
            VOLUME_CTRL, 
            vol & 0x7F);
}



void midi_modwheel(byte channel, byte vol) {
    midiMsg(CONTROLLER_CMD | (channel & 0xF), 
            MODWHEEL_CTRL,
            vol & 0x7F);
}
  
void
check_analog()
{
    // Read the Potentiometer
    volume_now= (analogRead(VOLUME_PIN) / 8);
  
    if(volume_now != volume_past){
        midi_volume(MIDIchannel, volume_now);
        //delay(1);
        volume_past=volume_now;
    }
}



void
toggle_button()
{
    modwheel_toggle = !modwheel_toggle;
    midi_modwheel(MIDIchannel, modwheel_toggle ? 127 : 0);
}

void
debounce_read_button()
{
    static bool cur_state;

    cur_state = digitalRead(SWITCH_PIN) ;

    // only if there's a transition
    if(cur_state != current_digital_state){
        delay(DEBOUNCE_TIME);
        if(digitalRead(SWITCH_PIN) == cur_state){
            current_digital_state = cur_state;
        }
    }
}


void
check_digital()
{
    debounce_read_button();

    // only on falling edge
    if(current_digital_state == LOW && prev_digital_state == HIGH){
        toggle_button();
        // delay(LOCK_INPUT_TIME);
    }
    prev_digital_state = current_digital_state;
}



void 
setup() 
{
    pinMode(SWITCH_PIN, INPUT); 
    digitalWrite(SWITCH_PIN, HIGH);
  
    pinMode(LED_PIN,OUTPUT);   // declare the LED's pin as output

  
    for (x=1; x<=4; x++){
        digitalWrite( LED_PIN, HIGH );
        delay(300);
        digitalWrite( LED_PIN, LOW );
        delay(300);
    }

 
        
    digitalWrite(LED_PIN,HIGH);  

    Serial.begin(31250);  //start serial with midi baudrate 31250
    Serial.flush();
}


void 
loop() 
{
    check_analog();
    check_digital();
}

Is refusing to compile, and gcc is dying with a massive spew, ending in:

/usr/bin/avr-gcc -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  -o applet/foodpedal.elf applet/foodpedal.cpp -L. applet/core.a -lm
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
/tmp/ccI5Yuuy.o: In function `midiMsg(unsigned char, unsigned char, unsigned char)':
applet/foodpedal.cpp:49: undefined reference to `Print::print(long, int)'
applet/foodpedal.cpp:50: undefined reference to `Print::print(long, int)'
applet/foodpedal.cpp:51: undefined reference to `Print::print(long, int)'
make: *** [applet/foodpedal.elf] Error 1

Ah crap, the YABB cut me off.

The first part of the error spew is here:

# Here is the "preprocessing".
# It creates a .cpp file based with the same name as the .pde file.
# On top of the new .cpp file comes the WProgram.h header.
# At the end there is a generic main() function attached.
# Then the .cpp file will be compiled. Errors during compile will
# refer to this new, automatically generated, file. 
# Not the original .pde file you actually edit...
test -d applet || mkdir applet
echo '#include "WProgram.h"' > applet/foodpedal.cpp
cat foodpedal.pde >> applet/foodpedal.cpp
cat /usr/local/share/arduino/hardware/cores/arduino/main.cxx >> applet/foodpedal.cpp
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c -o /usr/local/share/arduino/hardware/cores/arduino/pins_arduino.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:26:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:65: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:66: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:67: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:73: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:74: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:75: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:81: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:82: warning: initialization makes integer from pointer without a cast
/usr/local/share/arduino/hardware/cores/arduino/pins_arduino.c:83: warning: initialization makes integer from pointer without a cast
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring_analog.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring_analog.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring_analog.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/local/share/arduino/hardware/cores/arduino/wiring_analog.c: In function 'analogRead':
/usr/local/share/arduino/hardware/cores/arduino/wiring_analog.c:40: warning: unused variable 'ch'
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring_digital.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c: In function 'pinMode':
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c:37: warning: cast to pointer from integer of different size
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c: In function 'digitalWrite':
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c:79: warning: cast to pointer from integer of different size
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c: In function 'digitalRead':
/usr/local/share/arduino/hardware/cores/arduino/wiring_digital.c:97: warning: cast to pointer from integer of different size
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c: In function 'pulseIn':
/usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c:48: warning: cast to pointer from integer of different size
/usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c:53: warning: cast to pointer from integer of different size
/usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.c:58: warning: cast to pointer from integer of different size
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring_serial.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring_serial.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring_serial.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/wiring_shift.c -o /usr/local/share/arduino/hardware/cores/arduino/wiring_shift.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/wiring_shift.c:25:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/bin/avr-gcc -c -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  /usr/local/share/arduino/hardware/cores/arduino/WInterrupts.c -o /usr/local/share/arduino/hardware/cores/arduino/WInterrupts.o 
In file included from /usr/local/share/arduino/hardware/cores/arduino/wiring_private.h:30,
                 from /usr/local/share/arduino/hardware/cores/arduino/WInterrupts.c:33:
/usr/lib/gcc/avr/4.3.2/../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/usr/bin/avr-g++ -c -mmcu=atmega168 -I. -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os /usr/local/share/arduino/hardware/cores/arduino/HardwareSerial.cpp -o /usr/local/share/arduino/hardware/cores/arduino/HardwareSerial.o 
/usr/bin/avr-g++ -c -mmcu=atmega168 -I. -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os /usr/local/share/arduino/hardware/cores/arduino/WMath.cpp -o /usr/local/share/arduino/hardware/cores/arduino/WMath.o 
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/pins_arduino.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_analog.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_digital.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_serial.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_shift.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/WInterrupts.o

Son of a bitch, I hate YABB.

Trying one more time to get the damned error spew:

/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_analog.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_digital.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_pulse.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_serial.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/wiring_shift.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/WInterrupts.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/HardwareSerial.o
/usr/bin/avr-ar rcs applet/core.a /usr/local/share/arduino/hardware/cores/arduino/WMath.o
/usr/bin/avr-gcc -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino/hardware/cores/arduino -I/usr/lib/avr/include -Os -Wall -Wstrict-prototypes -std=gnu99  -o applet/foodpedal.elf applet/foodpedal.cpp -L. applet/core.a -lm
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
/tmp/ccI5Yuuy.o: In function `midiMsg(unsigned char, unsigned char, unsigned char)':
applet/foodpedal.cpp:49: undefined reference to `Print::print(long, int)'
applet/foodpedal.cpp:50: undefined reference to `Print::print(long, int)'
applet/foodpedal.cpp:51: undefined reference to `Print::print(long, int)'
make: *** [applet/foodpedal.elf] Error 1

This is with arduino-013 on : avr-libc 1:1.6.2.cvs20080610-2 avrdude 5.5-7 binutils-avr 2.18-4

Ah, I just needed to change one line of the Makefile, from

CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp

to:

CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/Print.cpp $(ARDUINO)/WMath.cpp

And now it builds and runs. Yay!

The problem was that I was using a makefile from 011 Arduino, and the Print.cpp library must be new to 013, I suppose.