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.
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.
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:
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.
Now move to Paths and replace each path with the appropriate location listed below:
AVR-GCC, GNU make, and AVRDude
AVR Header Files
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.
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 (<>).
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.
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.