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.

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:



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