"In function 'delay': Undefined reference to 'yield' ld returned 1 exit status

Hi everyone,

I'm trying to implement the second project in the Arduino book, and I'm getting some errors that I can't figure out. Here is my code. and then the error:

int switch_state = 0;

void setup()
{
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, INPUT);
}

void loop()
{
switch_state = digitalRead(2);

if(switch_state == LOW)
{
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
else
{
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(250);

digitalWrite(4, HIGH);
digitalWrite(5, LOW);

delay(250);
}

C:\Users\JOOSEP~1\AppData\Local\Temp\build4387004063794694035.tmp/core.a(wiring.c.o): In function delay': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring.c:114: undefined reference to yield'
collect2.exe: error: ld returned 1 exit status
Error compiling.

Any thoughts as to what this could be? I'm running Arduino 1.6.4 on a Window 8.1 Dell.

OK, so now I hooked it up to the Arduino board to run it, and I get a different error:

avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

So apparently I wasn't on the right port. Issue resolved!

Do remember what you did to solve the first issue (delay/yield)?

AstroFloyd:
Do remember what you did to solve the first issue (delay/yield)?

That error implies that something weird is wrong with your AVR board package (like, Arduino.h and wiring.c versions are mismatched)... What version of IDE, what version of AVR board package, and what board are you using?

Hi @DrAzzy, thanks for looking into this. I just got back here to report the solution I found.

I am using the CLI Makefile that comes with the BlinkWithoutDelay.ino example in the Arduino package. In that Makefile, the hooks.c file is not compiled/linked. By changing

SRC = \
    $(ARDUINO_CORE)/wiring.c \
    $(ARDUINO_CORE)/wiring_analog.c $(ARDUINO_CORE)/wiring_digital.c \
    $(ARDUINO_CORE)/wiring_pulse.c \
    $(ARDUINO_CORE)/wiring_shift.c $(ARDUINO_CORE)/WInterrupts.c \
    $(foreach l,$(USERLIBS),$(wildcard $(HOME)/sketchbook/libraries/$l/*.c)) \
    $(foreach l,$(ARDLIBS),$(wildcard $(ARDUINO_DIR)/libraries/$l/*.c))

to

SRC = \
    $(ARDUINO_CORE)/hooks.c \
    $(ARDUINO_CORE)/wiring.c \
    $(ARDUINO_CORE)/wiring_analog.c $(ARDUINO_CORE)/wiring_digital.c \
    $(ARDUINO_CORE)/wiring_pulse.c \
    $(ARDUINO_CORE)/wiring_shift.c $(ARDUINO_CORE)/WInterrupts.c \
    $(foreach l,$(USERLIBS),$(wildcard $(HOME)/sketchbook/libraries/$l/*.c)) \
    $(foreach l,$(ARDLIBS),$(wildcard $(ARDUINO_DIR)/libraries/$l/*.c))

(note the added second line) around line 197, this is resolved.