Arduino Eclipse Development Environment for Mac OS X

This is a short guide on how to setup Eclipse for Mac OS X Lion (10.7) for use with Arduino in a relatively short amount of time.  Using this guide, Eclipse can be setup to program and download code onto Arduino microcontrollers in about 15 minutes by using the Arduino Eclipse Plugin.

Initial Steps

To begin, download the following:

Installing Eclipse on Mac OS X is quite simple: extract the Eclipse package to the /Applications/ folder or another convenient location.  Then simply drag the Eclipse.app file to the dock from the /Applications/eclipse/ folder.

Next, install the Arduino IDE.  Once again, this is just a matter of extracting the zip file somewhere and dragging the Arduino.app file to the Applications folder.

Installing the Arduino Eclipse Plugin

Note: If this part of the instructions seems to be outdated, head over here and follow the instructions.  This is a modified version of those instructions specifically for Mac OS X and the plugin version 1.1.7. 

Now that Eclipse is installed, start it and choose a workspace (the default will work fine).  If this is the first time Eclipse has been opened, close the welcome screen.  Then, navigate to Help -> Install New Software and add a new site: http://www.baeyens.it/eclipse/update site/.  Check the latest arduino eclipse extensions under arduino and click next.

Finish going through the installation and restart eclipse when prompted at the end.

Configuration

The last part is merely a matter of configuration.  Eclipse should now be loaded with the workspace visible.  From the application menu, navigate to Eclipse -> Preferences (shortcut command + ,) and then Arduino -> Arduino in the Preferences pane.

In order for Eclipse to use proper compilers and libraries for Arduino, the location of the Arduino IDE must be set.  Users familiar with Mac OS X may know that .app files are actually just containers for application files (right click on any app and choose Show Package Contents in Finder).  The files needed by the plugin are located in the Arduino.app container.  If the Arduino.app application was added to the /Applications/ folder simply copy and paste this path into Arduino IDE path:

/Applications/Arduino.app/Contents/Resources/Java

If the Arduion.app application was installed to another location, simply modify this path appropriately.

Note: Sometimes simply copying and pasting this path does not work, and the location must be browsed to instead.  In the Finder file browsing window, browse to this path directly by pressing command + shift + g.

Next, in preferences move to AVRDude and copy this path into the AVRDude config file field. Once again, and from now on, modify the path if the Arduino.app was installed to another location.

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf

Now move to Paths and replace each path with the appropriate location listed below:

AVR-GCC, GNU make, and AVRDude

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin

AVR Header Files

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/include

Also be sure to check off Disable search for system paths at startup so these paths are not reset next time Eclipse is opened.

Additional Recommended Configuration

In Preferences, navigate to General -> Workspace and check Save automatically before build.

Under C/C++ -> Indexer it may be necessary to check Index unused headers and Index source and header files opened in editor.  Some installations also do not seem to automatically index the HardwareSerial library, and Eclipse will mark it as not able to be found.  Therefore, under Files to index up-front append “HardwareSerial.h” onto the end without quotes.

The Eclipse environment is now ready to create a new Arduino project.

Creating An Arduino Project In Eclipse

To start a new project using the plugin, go to File -> New -> Project… in Eclipse and select New Arduino sketch from the Arduino folder.  Click next and name the project, then click next again and choose the Arduino Board that will be programmed from the drop down menu.  Then type in the port where the board is located (e.g. /dev/tty.usbmodemfa131).  To find out what port the board is using, plug it into the computer and check using the Arduino IDE application or open terminal and type the following command to list external devices.

ls /dev/tty.*

If the board is not available, leave the port field blank or use a placeholder value to change later.  Click finish and the new project will be created.

Importing A Library

Another great feature of the Arduino Eclipse plugin is the ability to import libraries quickly.  To import a library to a project, right click on it in the project explorer and choose import.  Under the Arduino folder, choose Import a arduino library in the current project and choose next.  Next, browse to or type the location of the library to import (e.g. the Servo library is located at /Applications/Arduino.app/Contents/Resources/Java/libraries/Servo) and click finish.

To use the library, simply include it in the project header file (e.g. #include “Servo.h”).  Note that code copied from the Arduino IDE using an imported library will need to be changed so that the include statements use double quotes (“”) instead of angle brackets (<>).

Indexer Problems

If, at this point, Eclipse is underlining a lot of code in red, save and build the project first.  If it is still underlining code in red, then try going to Preferences, C/C++ Settings -> Indexer and uncheck Enable indexer, click Apply, recheck it, and click OK.  This should re-run the indexer.  It may also help to open header or cpp files that contain objects or functions that cannot be found when the indexer is re-run.  This seems to be a bug in the Eclipse indexer for Mac.

For all other troubles, here is a link to a thread that was very useful.

Conclusion

After reading this short tutorial, you should be able to configure an Arduino programming environment in Eclipse for Mac OS X relatively quickly.  A lot of credit is due to Jantje for making such a fantastic plugin!  Please leave comments if you appreciate this tutorial or have suggestions.

14 thoughts on “Arduino Eclipse Development Environment for Mac OS X

    • I’m glad to hear it worked for you.

      Unfortunately I don’t know of a way to monitor the serial port from within Eclipse. However, you can still use the Serial Monitor program in the Arduino IDE just fine. I personally use CoolTerm [http://www.macupdate.com/app/mac/31352/coolterm] for Mac because it’s very clean and simple to use. Just make sure you set the baud rate in your code and in CoolTerm to match.

      • Thanks for the hint again. I have just installed Coolterm.

        Just one more question: I have got a few libraries with a ifdef checking Arduino’s version and I am using Arduino V1. However, when I build it from Eclipse it seems to not pick up this variable. Thus, I guess I have to specify that somehow. Would you know how?

        That is the example.

        #if defined(ARDUINO) && ARDUINO >= 100
        #include “Arduino.h”
        #else
        #include “WProgram.h”
        #endif
        #include

    • I have just realized that my problem is actually related to imported libraries. For some reason the libraries are not compiling because they can’t find Arduino.h. The files created by the Arduino plugin can find it, tough.
      Any clues?

  1. Make sure your libraries use double quotes instead of angular brackets.
    #include “Arduino.h” instead of #include <Arduino.h>

  2. Great explanation!! I lost one day to try to configure my eclipse environment.
    but I have a problem in uploading the sketch: “AVRDude Upload has encountered a problem” in Details I read: Could not initializate class gnu.io.CommPortIdentifier”. Please help me.
    Ciao
    Francesco

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>