Sunday, May 23, 2010

Arduino: undefined reference to `loop'

Ok, since this is the second time this has baffled me, I am making a note to myself. It turns out you cannot have a library with the same name as the pde file.

This is the example that got me. The Arduino project .pde file is a test of an accelerometer library (Adxl345.cpp, .h). Here is what the directory listing looks like.
.../sketchbook/Adxl345/Adxl345.pde
.../sketchbook/Adxl345/Adxl345.cpp
.../sketchbook/Adxl345/Adxl345.h

This yeilds the cryptic error
undefined reference to `loop'

or sometimes
undefined reference to `setup'

or both. The fix is to rename the Arduino project as anything other than "Adxl345". Using "Save As" in arduino should do the trick. This is what the listing looks like that works:

.../sketchbook/Adxl345_test/Adxl345_test.pde
.../sketchbook/Adxl345_test/Adxl345.cpp
.../sketchbook/Adxl345_test/Adxl345.h.

4 comments:

BBC-Micro 32K said...

Thank you thank you thank you....
Much appreciated x 3 :-)

bigcmos said...

+1 Thanks!

Morten Hilbert said...

thank you very much!

Eric said...

perfect thank you. i was lucky with google