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:
And select “Arduino” -> “Add library to the selected project”
Eclipse will present you with a window to select the needed libraries from a list:
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:
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:
- Do not change file locations using your OSs file manager e.g. the finder in Mac OSX, otherwise Eclipse will get confused.
- 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…”
Eclipse will present another window :
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”:
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:
Once you’ve proceeded with “Ok” the library will have been removed from the Project