Electronic – arduino – Troubleshooting Eclipse IDE for Arduino

arduinoeclipse

I have been using Arduino IDE for sometime with my Arduino Uno. Recently I heard about Eclipse and I thought give it a shot. I downloaded the c++ version and installed the AVR plugin. Then I tried to configure it following instructions from here: http://www.arduino.cc/playground/Code/Eclipse

When compiled the library, there was some error about 'arduino.h' not found. When I copied that file to the core library, there were more errors now.

Then I downloaded the Eclipse blink example from https://github.com/allgood38/Arduino-Blink-Eclipse-Project. It comes with its own arduino core library and compiled without any troubles. Then I uploaded it to Arduino Uno within the Eclipse itself. Everything went fine except the led on the Uno is not blinking. It just stays ON.

I have tried uploading the compiled HEX file with other program but still the result is same. Please help me to figure out what's wrong here..

If there is anybody out there who have successfully integerated arduino 1.0 with the latest version of Eclipse in windows 7, please post the URL that you have referred.

EDIT: Finally compiled a blinky project without errors. But there is still error on the CoreLibrary project. Here is the screen shot:

enter image description here

Best Answer

I just built the Arduino 1.0 core as a static library in Eclipse and using Windows 7. One thing you didn't mention is that you have to get pins_arduino.h from somewhere as well. For the Uno, which uses the ATMega328P, I believe, I think you want the "standard" variant.

  • I copied into the static library project all of the files from: hardware\arduino\cores\arduino
  • I also copied into the static library project the pins_arduino.h file from: hardware\arduino\variants\standard

Could it be you just got the wrong pins_arduino.h file for your target chip? Also are you sure you have the right chip and clock speed selected under Project Settings => AVR => Target Hardware?

I would delete your Arduino Core static library project, start over by downloading the Arduino 1.0 zip file from arduino.cc, and make a new project from scratch. I just redid the process a couple times to make sure there were no problems and it's pretty quick to apply the project settings once you've done it once (took me < 5 minutes the second time).

Edit WProgram.h is deprecated in Arduino 1.0. It has been replaced by Arduino.h. Arduino libraries need to support both through #defines on the ARDUINO constant as described here. You need to define ARDUINO for the compiler as well in your main project, which you would do under Project Settings => AVR Compiler => Symbols and Project Settings => AVR C++ Compiler => Symbols respectively. You're going to want add a new Define Syms (-D) named ARDUINO with value 100 in both places I believe (ARDUINO=100).

Edit 2 I also had to explicitly include Arduino.h at the top of my blink.cpp source file (where setup and loop are defined), not sure how to do avoid compiler errors without it.

Edit 3 If you need to use Arduino Libraries, then you need to put the cpp and h files from the Arduino Library root folder into the arduinolib source folder, and any cpp and h files from the Arduino Library utility folder in an arduinolib/utility folder and include both arduinolib and arduinolib/utility in the project directory include paths (ala Project Settings => C/C++ Build => Settings => Tool Settings => AVR Compiler => Directories and Project Settings => C/C++ Build => Settings => Tool Settings => AVR C++ Compiler => Directories). You should only include those libraries in this folder that you actually use or the image will be bloated, presumably by way of each library's global variable declarations. A better way to go is probably to have separate static library projects for each Arduino library you want to use and place a project dependency on them from your main project, but that's a bit more work (could pay off in the long run though).