I am having a problem that I think goes back to libraries, as it only crops up in sketches that use a library.
At compile, I get a message similar to this:
undefined reference to 'Stepper::setSpeed(long)' - this one is from the stepper demo sketch that refers to the Stepper library - Stepper.h
the Servo demo gives me this:
undefined reference to 'ServoTimer1::attach(int)'
the list goes on... any sketch that uses a library gives me a similar error at compile and in each case, I have the library installed in my Arduino/Hardware/Libraries folder and they are duly linked by navigating in the Arduino IDE via Sketch/Import Library/select library and show up in the sketch with the #include... line at the top just as you would expect. Each library folder contains the appropriately named .cpp file and .h file. The files used to each contain an .o file as well, but I moved those all to another folder as someone I trust suggested that they should not be in there(she says she deletes them, but I moved them into a folder for safekeeping).
I am pretty new to Arduino, but I have poked around and searched and struggled with this and I am stumped...
any help is appreciated.
thanks,
George
George, I'm pretty sure the missing .o files are the cause of your problem. Your error message is exactly what you'd expect to see if the binary link module was missing. Interestingly, in my system if I delete or move the library .o files, they are rebuilt when I build a project that uses them, but apparently not for you? Move the .o files back where the IDE expects them, and I bet that'll resolve your problem.
Actually, I was having the problem before and I tried to remove the .o files as a possible fix. Unfortunately, It didn't fix it, and in fact doesn't seem to make any difference one way or the other. I don't see it rebuilding the .o file in the folder, but that would not surprise me, since I don't know what it does. thanks for the suggestion though.
Can you build the eeprom_clear example? I can build this with no problem, and furthermore, if I delete hardware/libraries/EEPROM/EEPROM.o beforehand, it is nicely rebuilt for me. What operating system are you working with? It might be useful to reinstall your Arduino software; the linker is clearly not finding your library binaries for some reason.
I tried the EEPROM sketch you recommended with the .o file removed from the folder and it gave me the same undefined reference error when I try to compile, and it does not rebuild the .o file automatically. However, when I replaced the .o file in the EEPROM Library folder, and tried to recompile the sketch - this fixes the undefined reference error I was seeing. I am still puzzled why the IDE doesn't create this file for me if that is what others report. Also, the trusted expert that told me to delete the .o files must have been counting on this recreation of the .o file every time you recompile... that leaves me struggling with two issues, a few of the libraries I have don't have the .o file in their library folder and when I compile the related sketch, it is not generated and the undefined reference error persists. So, I need to either get a copy of the .o file or figure out how to trigger the IDE to generate one for me. Just for grins, I redownloaded the ServoTimer1 library from the Arduino playground and it does NOT include a .o in the zip. This tells me that I have to figure out how to trigger my IDE to make one...
I am using Arduino rev 0011 Alpha on MAC OS X 10.4.11.
It sounds to me like your analysis is exactly correct. Hopefully, one of the posters familiar with the IDE innards (mellis? :)) will chime in with suggestions on why the libraries .o files are built on some platforms but not others. Is your "trusted expert" running the Arduino IDE on a different OS than you are?
The .o files should be recompiled when you start the Arduino IDE, when you switch boards (in the Tools > Board menu) or when you compile a sketch. Try setting build.verbose to true in the Arduino preferences file and relaunch the IDE. What files does it build (can you post the output here)?
Ok, I relaunched the IDE and I am still not getting the .o files in each library folder where they are missing. You asked me to change build.verbose to TRUE (done) and post the output here. I am assuming that you mean all that gibberish in red in the bottom window... here is the output from the servo driver example sketch off the Arduino website:
(fwiw, I have always had a lengthy display of red error messages in that window, even with sketches that work fine, so I have always wondered what it all is, but ignored them - the undefined reference is the one that shows up on sketches that refer to a broken library)
thanks for the help!
main.c:203: warning: TIMER2_COMP_vect' appears to be a misspelled signal handler main.c: In function 'uartPutChar': main.c:238: error: 'USR' undeclared (first use in this function) main.c:238: error: (Each undeclared identifier is reported only once main.c:238: error: for each function it appears in.) main.c:238: error: 'UDRE' undeclared (first use in this function) main.c:240: error: 'UDR' undeclared (first use in this function) main.c: In function 'uartGetChar': main.c:261: error: 'USR' undeclared (first use in this function) main.c:261: error: 'RXC' undeclared (first use in this function) main.c:263: error: 'FE' undeclared (first use in this function) main.c:264: error: 'DOR' undeclared (first use in this function) main.c:266: error: 'UDR' undeclared (first use in this function) main.c: In function 'main': main.c:806: error: 'OCR2' undeclared (first use in this function) main.c:808: error: 'TCCR2' undeclared (first use in this function) main.c:809: error: 'TIMSK' undeclared (first use in this function) main.c:809: error: 'OCIE2' undeclared (first use in this function) main.c:815: error: 'UCR' undeclared (first use in this function) main.c:815: error: 'TXEN' undeclared (first use in this function) main.c:815: error: 'RXEN' undeclared (first use in this function) main.c:818: error: 'UBRRL' undeclared (first use in this function) main.c:866: error: 'USR' undeclared (first use in this function) main.c:866: error: 'RXC' undeclared (first use in this function) o: In function setup':
undefined reference to ServoTimer1::attach(int)'o: In function loop':
o: In function `__static_initialization_and_destruction_0(int, int)':
Okay, I tried something else - I still have version 10 , so I tried to move some of the libraries that don't have .o files in the library folder from the rev 11 libraries folder into the libraries folder of the version 10 and change board type. This did trigger the rev 10 IDE to build some .o files but not all. I am willing to believe there is something wrong with the libraries that still have the .o files missing now. Mellis, you may be interested in this report from a IDE developers point of view - I am running Mac OS 10.4.11 and the Arduino IDE rev 0011 Alpha.
When did you get the output you posted in the previous post? Was there any white text above the red messages? Do you have any extra (non-standard) libraries? It's possible that if there's an error in one library, the rest won't get built.
I found this thread searching on a similar problem I'm having. I get the exact same "undefined reference" error for any sketch with a non-core library. However, I'm using CosineKitty's Windows Command Line (abuild.bat) utility and not the IDE (my Arduino IDE works fine, I'm using the command line utility so I can work in Eclipse).
I hope that helps triangulate the problem (and maybe solve mine at the same time
I experimented with moving various libraries out of the Libraries folder and I think that the problem was irregular libraries that gummed up the works.