Importing Libraries and other existing code

Once the first test Blink sketch is running most Programs will include one, or more libraries.

When using Eclipse ALL libraries to be used will have to be imported, including standard libraries that come with the Arduino IDE or are added by the Teensyduino plugin into the Arduino IDE.

Highlight your project in the Project Explorer:

Screen Shot 2013-07-13 at 8.16.36 AM

And select “Arduino” -> “Add library to the selected project”

Screen Shot 2013-07-13 at 8.18.08 AM

Eclipse will present you with a window to select the needed libraries from a list:

Screen Shot 2013-07-13 at 8.28.44 AM

This list includes all libraries that are installed with the Arduino IDE and the folder where you have your personal libraries located. Once you click on “Finish” the imported library will appear in the Project explorer:

Screen Shot 2013-07-13 at 8.30.39 AM

When importing, Eclipse does not move or copy any of the referenced libraries but rather generates Eclipse-internal references to to these. So here are two things to consider:

  1. Do not change file locations using your OSs file manager e.g. the finder in Mac OSX, otherwise Eclipse will get confused.
  2. As the library files are not copied but just referenced, be aware that when you decide to change to change it, you will be changing it in its central location, which is possibly referenced by other projects in Eclipse or in the Arduino IDE. And these projects may not agree with the change you made 😉

Here is an alternative way of importing libraries:

When you have highlighted your project in the Project Explorer as shown in the first screenshot, right-click on it and select “Import…”

Screen Shot 2013-07-13 at 8.41.03 AM

Eclipse will present another window :

Screen Shot 2013-07-13 at 8.42.01 AM

This method will not only provide you with the opportunity to import Libraries into your project but also to reference other folders with existing code that you may want to use in you project.

If a library is not needed anymore, removing the reference from the project in the Project Explorer is easy to do and the I2C library is really not needed in the simple T3_Blink project:

Right-click on the library in the Project Explorer and select “Delete”:

Screen Shot 2013-07-13 at 8.53.36 AM

This will only remove the references to these files from the Project. It will not delete or move any library files as Eclipse will tell you:

Screen Shot 2013-07-13 at 8.55.22 AM

Once you’ve proceeded with “Ok” the library will have been removed from the Project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: