2

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

0xakhil
  • 2,225
  • 7
  • 35
  • 33
  • What OS are you doing this on? – Raul Marengo Jan 04 '12 at 08:45
  • OS is Windows 7 – 0xakhil Jan 04 '12 at 08:51
  • Cool, unless someone gives you an answer, I will try to replicate this at lunch time if possible. I have a Win7 dual boot with Eclipse on it to test this on. – Raul Marengo Jan 04 '12 at 08:53
  • @Ramengo Which IDE are you currently using? – 0xakhil Jan 04 '12 at 09:01
  • Just the Arduino one is plenty for me at the moment. When I get started with the ADK Mega I will need to use Eclipse but that will be more down to having to build the Android App than anything else. – Raul Marengo Jan 04 '12 at 09:03
  • I have used LPC Xpresso which is a variant of Eclipse. I find it is kind of inconsistent. Sometimes it will build a project without any error. But if you try to compile the same thing another time, it may show a lot of errors. >_ – 0xakhil Jan 04 '12 at 09:14
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/2137/discussion-between-ramengo-and-0xakhil) – Raul Marengo Jan 04 '12 at 09:24
  • Can you still use the actual Arduino IDE to upload Blink to your Uno, or have you inadvertently altered the fuse settings of the Mega328? – vicatcu Jan 04 '12 at 15:05
  • Yes Arduino IDE works perfectly fine.. – 0xakhil Jan 04 '12 at 15:10
  • IntelliJ Idea is a possible IDE also. See http://youtrack.jetbrains.com/issue/CPP-364 – Bryce Jun 11 '14 at 19:49

2 Answers2

3

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).

vicatcu
  • 22,499
  • 13
  • 79
  • 155
  • Ok I will try everything again.. – 0xakhil Jan 04 '12 at 16:10
  • Where did you put the libcore.a file?? – 0xakhil Jan 04 '12 at 16:11
  • Where can I find WProgram.h? – 0xakhil Jan 04 '12 at 16:19
  • @oxakhil I built it from source. the .a file gets generated by the build process. Your "main" arduino program has to include the static library project as a dependency and will then use the built file. Basically I did "option 3" under the heading "Obtaining the Arduino Core Library " in the playground reference you lined to. – vicatcu Jan 04 '12 at 16:19
  • @oxakhil Updating my answer for details about WProgram.h this... – vicatcu Jan 04 '12 at 16:23
  • ArduinoCore library can be successfully compiled. But another blinky project cannot. Its showing error for all the arduino library functions. I have added the dependency on ArduinoCore project in the blinky project's preference. – 0xakhil Jan 04 '12 at 16:28
  • @oxakhil also please re-read my bullets as I edited them. – vicatcu Jan 04 '12 at 16:29
  • @oxakhil you might need to #include in your setup/loop source file as well (see edit2) with that I was able to build a Blink project that depended on the ArduinoCore static library project. Maybe I'll blog about this later... – vicatcu Jan 04 '12 at 17:04
  • When I try to build now, I get compile error on IPAddress.h.. '_address' was not declared in this scope IPAddress.cpp /arduino_core/src line 7 C/C++ Problem – 0xakhil Jan 04 '12 at 17:43
  • @oxakhil, what libraries are you using? can you post your sketch source code somewhere (e.g. pastebin.com) – vicatcu Jan 04 '12 at 18:06
  • I copied the libraries from the Arduino 1.0. Here is the sketch: http://pastebin.com/Rew47LrN – 0xakhil Jan 04 '12 at 19:27
  • Finally, after all the tweaking there is just one warning left: – 0xakhil Jan 04 '12 at 19:47
  • '[C@a81fd' has virtual method 'printTo' but non-virtual destructor Printable.h – 0xakhil Jan 04 '12 at 19:48
  • Is that warning totally okey??? – 0xakhil Jan 04 '12 at 19:49
  • @oxakhil What happens if you don't include the libraries in your project at all? (I haven't included them in mine). You also shouldn't need to define main - that's built into the core library. Just implement setup and loop as you would in the Arduino IDE. – vicatcu Jan 04 '12 at 19:55
  • @oxakhil, I get no warnings or errors, and that's the way I like it... :-) – vicatcu Jan 04 '12 at 20:16
  • Now it started giving me compile errors for all the serial library functions in the blinky project. >_ – 0xakhil Jan 04 '12 at 20:44
2

On Linux, before I could get Eclipse to work properly, I had to go through the preferences and change all the Arduino paths from "custom" to "system":

enter image description here

Check your paths - especially for the "AVR Header Files" entry.

Majenko
  • 55,955
  • 9
  • 105
  • 187
  • Its already 'system' in the preferences for me. – 0xakhil Jan 04 '12 at 15:00
  • on a side note, I've heard that the avr-gcc tool chain (not arduino-specific) in linux is wrought with peril based on developers-list discussion of late... – vicatcu Jan 04 '12 at 15:08
  • What I'd like is a great editor... and then rely on the standard Arduino tool chain. – Bryce Jun 11 '14 at 19:49
  • Kind of like I've been doing with UECIDE? http://uecide.org - unstable beta at http://uecide.org/beta - it's a complete rewrite of the Arduino IDE with much better features. – Majenko Jun 12 '14 at 09:45