February 2010 -
Here are a few tips I picked up along the way.
First, you need to decide what step the error occurs in: Compile, Link, or Upload. You can look in the console window tab. Look for the text AVR Linker. If you see that then the compile completed and you are having a problem with linking.
General Linker Problems
You can get a lot of information by setting: In Project/Properties first select All Configurations before making the changes they recommend. In C/C++ Build / Settings / Assembler / Objects add an Xlinker option of " -verbose". Note the space in front of the dash! Next time you link you'll get a face full of information. Each time the linker looks for a library you'll see it try the paths one at a time, reporting warnings until it finally finds the file. As long as it finds each library file you're fine.
General AVR Upload Problems
I ran the AVRDude uploader in a Windows cmd window so that it would be easy to vary the parameters. I first went to my Arduino IDE config file and added upload.verbose=true then I ran the IDE and had it upload a small sketch. You'll see that the IDE shows the AVRDude command it used. Copy that and paste it into a text editor.
In Eclipse go to Window / Preferences. Navigate to AVR / AVRDude. Check the box Log Internal AVRDude Output to Console. Now when you do the upload your console will show what's going on. Compare the command that Eclipse is using with the one that the Arduino IDE is using.
In my case, I was getting stk500_getsync(): not in sync: resp=0x1e from AVRDude in Eclipse. I copied the command Eclipse was using and pasted it into a cmd window. Eventually I found that AVRWin was not working for me. If I used the version that came with Arduino IDE I could upload a hex file created by Eclipse. I ended up pointing Eclipse to the Arduino version of AVRDude.
Error: No rule to create main.o
Fix: I had this because I created the project as C, but my main file was main.cpp. Rather than fight it I created a new project as a C++ project and did a drag-drop within the Eclipse project explorer.
Error: Compiler Cannot Find Servo.h or some other library file you added with an include statement
Fix: Remember that when the file you include is named Servo.h you have to
Error: attempt to open C:/dev/eclipse/MyCPPTemplate/servo failed
The Linker cannot Find -lServo or some other library file you added in the Project / Properties / C/C++ Build / Settings / AVR C++ Linker / Libraries
Fix: When you have included a library named "Servo" you need to:
Note that sometimes a file you included will depend upon another library and you have to add that to your Linker Libraries list too. I found that LibServer.so depended upon LibWMath.so.
Error: Eclipse loses backspaces in my library directories.
Fix: I don't know, the problem went away. I had this in my project / properties
in the linker libraries line and somehow the workspace_loc is expanding to backslashes, which get ignored. The correct expansion is C:/dev/eclipse/MyCPPTemplate/arduino. I fixed that by removing the use of the workspace_loc variable and put in this:
Now it compiles and links without error. Jesus that was a waste of time. Since then I've gone back to using the workspace_loc and it works fine. I wonder if I had some problem with my way of importing files into the Eclipse project? In any case, I now always drag-drop files and things have settled down.
Jim Schrempp is a sometimes freelance writer (only Vanity Press will publish his work) living in Saratoga, California. His writings have appeared on numerous pages on his own web site. The opinions expressed in this piece are those of the writer and do not necessarily represent those of anyone else (although Jim wishes more people shared his opinions)