Windows/Linux/Mac Eclipse plugin to compile and upload arduino sketches

Klaus
Not sure why you can't use Serial. All this works fine for me.
I assume you are referring to the console output that tells you that serial doesn't work. I ask because the eclipse indexer sometimes behaves weird and sees errors that are not errors.
As you already had plenty of problems it is -in my experience- best to just start from scratch with a new eclipse installation.
Best regards
Jantje

Jantje, thanks - I had the name of the folder .. /Arduino-extras/boards.. so this was the issue. Now I can compile, however eclipse shows:
Symbol 'Serial' could not be resolved
Method 'print' could not be resolved
Method 'println' could not be resolved
It compiles without error and I get hex files (hex not shown in Project Explorer).

But there is an issue which would be nice to fix - related to pins_arduino.c.
I am using (and maybe others as well) a special way how "pins_arduino.c" defines a set of various boards. To make the story short:

  1. in folder ..hardware\Arduino\cores\arduino there is "pins_arduino.c" which contains ie:
    ...
    #if defined(AVR_ATmega128)
    //* pin defs for SOC-Amber128 web serverboard
    #include "pins_amber128.cxx"

#elif defined(AVR_ATtiny45 )
//* pin defs for Avr attin45
#include "pins_attiny45.cxx"
...
2. in that folder there is a set of .cxx-es with respective boards pins definitions.
3. your setup attempts to compile everything with .cxx, .c in that folder which creates errors, of course.
4. so I had to remove all .cxx-es and create a single "pins_arduion.c" for the board of choice in order to compile the stuff properly.
p.

Adding the line

extern HardwareSerial Serial;

to a header file will "fix" the errors shown by eclipse regarding the "Serial" reference.

// Klaus

Klaus
extern HardwareSerial Serial; will not fix the issue as the code compiles. (it should be defined as I include WProgram.h. It is an eclipse indexer problem.

Pito
Please see the freshly released web pages with more documentation. on Arduino Eclipse IDE named Sloeber - Welcome! There is a faq that should answer your questions.

Best regards
Jantje

Eclipse tells me there are bugs in my code but it compiles ok.
Eclipse compiles you code in 2 ways. Once when you request a build (when you press on the hammer) and ones when you change code (save a file). The compiler is responsible for the build and the indexer is responsible for the continuous build.
The bugs (the red animals in the code) you see in the code can be found by any of the 2. The indexer behaves weird and sometimes doesn't find declarations that it knows. In that case you have the bug without a bug (in other words the code compiles ok).
Setting the option windows->preferences->C/C++->indexer->index unused headers seems to have fixed the issue on my system.

.. so why you compile *.cxx files?
:slight_smile:

Pito
Yes indeed the *.cxx question is not answered directly in the FAQ. It is indirectly answered in "I have modified my Arduino setup and... "
But to give you some background:
I don't compile *.cxx files XD
My plugin uses avr eclipse that uses cdt, win avr and GNU compiler. CDT uses eclipse
It is cdt (which is a C/C++ plugin for eclipse) that compiles *.cxx
If you have read the "How to keep the IDE and plugin compatible" you must have seen how to add *.pde file as to be handled by the compiler.
Unfortunately you can not remove *.cxx files as they are supported by default.
In my humble opinion it is better to avoid mixing files of different sources. Having the *.cxx somewhere else may fix your problem.

Best regards
Jantje

Seems a really great work !! but update site is broken :frowning:

Is there a lot of work to do a linux port?

All
The plugin (version 1.0.10) -now available on the update site- also works under linux (only tested on openSUSE)
Are there candidates to test on other Linuxes?

I see in my site log that more than 100 downloads have already taken place. To those people: Please give feedback.

  • Did it work for you?
  • Were you stuck somewhere? (What exactly failed)?
  • Do you like it?
  • Which OS do you use?

I prefer it on the forum but you can also send your input to eclipse@baeyens.it

Version 1.0.10 also

  • excludes the examples folder when you import a library. This is (only?) useful for people who added pde files as source code.
  • No longer adds include folders to the assembler.

Best regards
Jantje

First off, I want to say - stellar job man! I am digging this! I have been trying to get Eclipse working for Arduino on and off for a while now.

I am game to be a tester for OS X.

Thus far, all is well. All but:

**** Build of configuration Release for project Arduino_test_002 ****

make all 
Building file: ../Arduino_test_002.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino" -I"/Users/nick/Documents/Home_Workspace/Arduino_test_002" -D__IN_ECLIPSE__=1 -DARDUINO=22 -Wall -Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"Arduino_test_002.d" -MT"Arduino_test_002.d" -c -o "Arduino_test_002.o" "../Arduino_test_002.cpp"
/bin/sh: avr-g++: command not found
make: *** [Arduino_test_002.o] Error 127

**** Build Finished ****

avr-g++ is not being found. I have no idea why though. avr-g++ is readily available on my $PATH.

Even more confusing, is when I have an AVR project, it sees and uses avr-gcc just fine.

Anyone have any clue to this?

Thanks in advance.

Monkeyknight
Thanks for trying this out on OS X. I don't own an OS X operating system so I can only help you with theory and experience from the port to OpenSuse.
The plugin code uses a full path to locate the avr-g++. For windows and Linux this means that adding avr-g++ to the path doesn't help. I guess this will be the same on OS X. In windows avr-g++ comes packaged with the IDE. In Linux it is not. Is avr-g++ delivered as part of the IDE in OS X?
Because avr-g++ is delivered differently per OS a part of the porting includes having setting different paths.
You can however set the paths yourself. As an experienced eclipse user that should be a piece of cake.

To set the paths yourself, as a work around, you do as follows:
Locate avr-g++, GNU make, the AVR header files and AVR dude on your system. (You don't need atmel part description files)
open eclipse and go to windows->preferences->arduino->paths. You should see something like this:

In your situation there will be errors. Change the paths.
Try again and hope there are no other incompatibilities.

Important Notes

  1. you will have to fix all the errors before you can save the preferences.
  2. Do not open any other tabs in the preferences as this may invalidate the changes you do.
  3. Best is to do the change, save, reopen the preferences, validate whether the change is done, if ok do cancel else redo.

If it works it would be nice if you told me what you had to change. This way I can modify the plugin to set these values correct.
Even better was if you changed the plugin yourself (with my help off-course).

Lots of good luck
Jantje

HA! Sweet!

All is great, except for some includes now!

**** Build of configuration Release for project Arduino_test_002 ****

make all 
Building file: ../Arduino_test_002.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino" -I"/Users/nick/Documents/Home_Workspace/Arduino_test_002" -D__IN_ECLIPSE__=1 -DARDUINO=22 -Wall -Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"Arduino_test_002.d" -MT"Arduino_test_002.d" -c -o "Arduino_test_002.o" "../Arduino_test_002.cpp"
In file included from ../Arduino_test_002.cpp:2:
../Arduino_test_002.h:9:22: error: WProgram.h: No such file or directory
make: *** [Arduino_test_002.o] Error 1

**** Build Finished ****

But this should be pretty simple.

I have some years of Eclipse experience, but to be honest most of the times I have used it I have not had to edit many paths. So this was not quite as obvious of an edit as it would have been to some.

Arduino Paths.tiff (131 KB)

The library was not building, because of some undefined refrences.

I had to add "#include <stdint.h>" to Arduino.h. I am not sure why, and in fact I am sure that I should not have to edit any of the Arduino core files.

Also I had to edit

#include "pins_arduino.h"

to

#include <pins_arduino.h>

Here are a few other edits:

pins_include.tiff (194 KB)

AVR Compiler Path.tiff (228 KB)

AVRDude Conf dir.tiff (109 KB)

I am not sure why, but the plugin will not take my edits for updating the avrdude path.

I edit it to point to: /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin

But it resets it to: /Applications/Arduino.app/Contents/Resources/Java/hardware/tools

Hi Monkeyknight
I see you are using Arduino 1.
The plugin is not compatible with Arduino 1. See my post on this topic in http://arduino.cc/forum/index.php/topic,81082.0.html
You should not have to edit the Arduino files. If the IDE works under OS X with these files there is no reason an eclipse plugin should have to change these files.
The only change you made that I can not explain is "I had to add "#include <stdint.h>" to Arduino.h"

On behalf of "I am not sure why, but the plugin will not take my edits for updating the avrdude path."
Have you followed the "important notes" in my previous post?

I see you are changing things in the project settings. Normally this is not needed. If you want to change it anyway it is better to change them in project properties-> C++- general > paths and symbols. Information is stored at several locations and you may undo your changes without knowing.

I'm wondering what you provided as input to the preference screen below.

Given your input it should work if you provide "/Application/Arduino.app/Contents/Resources/Java"
Can you try to change to this settings saave the preferences reopen the preferences and take a image from the avr path settings

Delete all the project (or even the workspace) selecting delete content on disk before you do a new test.
As far as I see it should work.
Best regards
Jantje

I just did an uninstall of Eclipse and deleted all my workbenches, and reinstalled on my Mac Mini. Life is good! Now I just have to do it to my Mac Book Pro's.

This is just killer! Perfect. After a bit, I think that I am going to look into porting over to the IDE version 1.0 though. It is kind of a downer that I have to use an old version of the Arduino IDE, but I tell ya what - It's still flippin' awesome!

Many thanks to you! May your code always compile the first time.

Thanks,
Nicholas

I'm testing your plugin un my linux (ubuntu 11) with an arduino Nano.
I'm having some linking problems with the arduino_atmega328p autogenerated project:
‘init’ was not declared in this scope main.cxx /arduino_atmega328p/arduino line 3 C/C++ Problem
‘loop’ was not declared in this scope main.cxx /arduino_atmega328p/arduino line 8 C/C++ Problem
‘setup’ was not declared in this scope main.cxx /arduino_atmega328p/arduino line 5 C/C++ Problem
Symbol 'DDRB' could not be resolved pins_arduino.c /arduino_atmega328p/arduino line 361 Semantic Error
Symbol 'DDRC' could not be resolved pins_arduino.c /arduino_atmega328p/arduino line 362 Semantic Error
Symbol 'DDRD' could not be resolved pins_arduino.c /arduino_atmega328p/arduino line 363 Semantic Error
...

Am I missing something?

Nicholas
Are you saying the plugin work fine on OSX with Arduino IDE 0023? That would be great.

turdusmerula
The init, loop and setup sound unknown to me.
Does you code compile? if so please read the section "Eclipse tells me there are bugs in my code but it compiles ok." in the faq at This page has been moved
How do you get to main.cxx? I have main.cpp?

About the errors in pins_arduino.h see "There are errors and warnings in the Arduino library." in the same FAQ

Note that in 1.0 these errors have been fixed :smiley:

Keep me posted

I am not positive which version it is. I didn't take a look. I will next time I boot it up though.

Thanks again!

Okay solved my problems. I just have to tell eclipse to exclude the main.cxx file from build and it works !

On ubuntu we have the 0022 installed and your plugins works, really great job thanks a lot :slight_smile:

One remaining question, where can I find on eclipse the output logs emitted by the Serial.print() command? thought I'd find it in the Console window but I failed.

turdusmerula
You need a serial communication program with the eclipse plugin. I use the serial monitor from the arduino IDE.
I'll make a todo to add this to the FAQ.
Best regards
Jantje