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

60 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

  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

  3. I can compile but when invoke AVR I get an alert:

    AVRDude does not support the project target MCU [ATmega328P]
    Please select a different target MCU if you want to use AVRDude.
    (Properties -> Target Hardware)

    Is it really impossible to develop for the Arduino Uno using Eclipse?

  4. Pingback: scheck media Blog - » erste Schritte mit dem Arduino Projekt

  5. Hello I just downloaded Eclipse juno for Mac OSX 64 bit and then i downloaded Arduino EID software1.0.1. Arduino.app was sent to the application folder. I opened eclipse juno and installed the plug in v2.0.4 and when i go to eclipse>preference>arduino i cannot select the arduino.app. It shows in the application folder that it is there but i cannot select it i tried writting the adress manually but it doesnt work i cannot select the ok button to save the changess I need help installing this.

  6. Hi there,

    I’m having problems building the NanodeUIP example in eclipse. It builds fine in the Arduino IDE.

    It is giving me the following error on building:
    /Applications/Arduino.app/Contents/Resources/Java/libraries/NanodeUIP/uip/unix/clock-arch.c:42:22: warning: sys/time.h: No such file or directory

    Any ideas?

    Thank you

    • Hi
      you say it is an error but the comment states it is a warning.
      Are you aware the plugin compiles at warning level “all” while the Arduino IDE 1.0 and lower uses a lower warning level?
      Best regards
      Janttje

  7. Hi!

    Excellent article – however, after installing Eclipse (Juno) and plugin v1.2.4, I get the following if I try to build an empty project for the Mega2560:

    Errors occurred during the build.
    Errors running builder ‘CDT Builder’ on project ‘Test’.
    Internal error building project Test configuration Release
    java.lang.NullPointerException
    Internal error building project Test configuration Release
    java.lang.NullPointerException

    Any ideas what’s going on?

    • It says it gives you errors but it actually succeeded building. You have to hit the build button and then the “Upload current project to AVR” button, both of which will give you errors. It WILL upload though.

  8. Hello, first of all congratulations for this great tutorial and apologize for my english, it’s not very good.
    I followed all the steps to the tutorial but I have a little problem… I can upload the program to the arduino but there are something that not works ok.
    If, for example, I write “Serial.begin();” I appear 3 errors like:
    1-”make:***[pruebaBlink.o]Error 1″
    2-”Method ‘begin’ could not be resolved”
    3-”Symbol ‘Serial’ could not be resolved”

    Thank you so much.

  9. Pingback: Notes on getting the Arduino Eclipse plugin working with reaDIYmate | My hovercraft is full of elks

  10. I installed it in mac osx lion. I can build a project. Everytime I upload it it says: ‘port /dev/tty.usbmodem26221 already in use. Try quiting any programs that may be using it’

    But it DOES upload the sketch successfully and it is run on the Arduino.

    I have no idea what is using the port. I closed the Arduino IDE.

  11. I imported the Wire library.
    Added “#include “Wire.h” in the header file.

    I keep getting:
    “/libraries/Wire/Wire.cpp:26:19: warning: twi.h: No such file or directory”

    I tried to include “twi.h” in the header also.

  12. Hi, I tried this and compilation works fine.
    But when I try to upload to my micro I get:
    Launching /Applications/Arduino_1.5.2.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino_1.5.2.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -patmega32u4 -cavr109 -P /dev/tty.usbmodemfd131 -b57600 -D -Uflash:w:/Users/mike/Documents/Programmieren/Eclipse/micro/Release/micro.hex:i
    Output:

    and thats it. Progress (avrdude) gets stuck and I can wait endlessly.

    Any suggestions?
    Serial Monitor works and gives Numbers like:
    305
    308
    312
    314
    315
    315
    313

  13. I’m impressed, I must say. Rarely do I come across a blog that’s both equally educative
    and amusing, and without a doubt, you’ve hit the nail on the head.
    The issue is an issue that too few people are speaking intelligently about.

    I’m very happy I stumbled across this during my hunt for something concerning this.

  14. This content is very informative but it took me a long time to find it in google.

    I found it on 13 spot, you should focus on quality backlinks building,
    it will help you to rank to google top 10. And
    i know how to help you, just type in google – k2 seo tips and tricks

  15. I do not leaave a lot of responses, but i did a few searching and wound up here Arduino Eclipse Development Environment for Mac OS X |
    Mechatronics Project Site. And I do have a couple of questions for you if you tend not to mind.
    Could it be only me or does it appear like some oof these responses appear as if they
    are coming from brain dead individuals? :-P And, if you are posting at
    other online sites, I’d like to keep up with everything new you have to post.
    Could you make a list of all of your communal pages like your linkedin profile,
    Facebook page or twitter feed?

  16. I see a lot of interesting articles on your blog. You have to
    spend a lot of time writing, i know how to save you a lot
    of work, there is a tool that creates unique, google friendly articles in couple of seconds, just type in google – laranita’s free content
    source

  17. I leave a response each time I appreciate a post on a website or if I have something
    to valuable to contribute to the conversation. Usually it is caused by the sincerness communicated in the
    post I browsed. And after this post Arduino Eclipse Development Environment for Mac OS
    X | Mechatronics Project Site. I was actually excited enough to drop a thought :) I do have 2 questions for
    you if you usually do not mind. Could it be only me or do a few
    of these responses look as if they are coming from brain dead individuals?
    :-P And, if you are posting on other online social sites, I’d like to
    follow you. Could you make a list every one of your social sites like your
    twitter feed, Facebook page or linkedin profile?

  18. Hi I am so excited I found your webpage, I really found
    you by error, while I was searching on Aol for something else, Nonetheless I am here
    now and would just like to say many thanks for a fantastic post and
    a all round enjoyable blog (I also love the theme/design), I don’t have time to browse
    it all at the minute but I have book-marked it and
    also included your RSS feeds, so when I have time I will
    be back to read more, Please do keep up the fantastic
    work.

    Here is my web page – anime free wiki

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>