Go Down

Topic: Keeping all libraries in the sketch directory (Read 1 time) previous topic - next topic


I know that you are supposed to place any external libraries under the "libraries" folder of the arduino install directory, but I have a project that uses several libraries that I have created for the project and mainly to keep all that code self contained and out of the main pde file.  However, I have tried to place the libraries in the same directory as the main PDE file so that I can more easily keep everything synced up in subversion (I work on this on multiple computers) and I don't want to have to keep going back and syncing up the libraries separately.  Also, just for the sake of being able to easily zip of the sketch folder and know that it contains everything it needs.

I've tried adding the header files to the sketch as a new tab, but that doesn't seem to work at all... don't even care if they should up in the arduino IDE.

Is this possible? And, if so, how to I include them in the main file for building?


All .h files, all .cpp files, and all .pde files in the sketch directory are opened as separate tabs when you open the sketch.

All .pde files are compiled, so there is no reason to tell one .pde file about any others, nor is there a way to.

All .cpp files whose .h files are included in a .pde file will also be compiled. All the .o files that are produced by the compiler will be linked by the linker, to produce the .hex file.

I've tried adding the header files to the sketch as a new tab, but that doesn't seem to work at all.

It's always worked for me. What evidence can you show that "it doesn't seem to work at all"?


Evidence is that is says it cannot find the file...
However, I had all the libraries in their own sub-directories as well. Will this not work?

I'm used to in win32 C++ I can just include it as "#include "mylib/mylib.h" and it will follow to the subdirectory just fine. I guess it's just this that is not supported.  

For organization's sake I would really like to have the subdirectories if there is any way to keep them.


Evidence is that is says it cannot find the file...

There is a difference between
#include <This.h>
#include "That.h".

Which were you using to cause the problem?


I tried both. Though, the file was in a subdirectory of the main sketch directory.  Are subdirectories supported at all?


Are subdirectories supported at all?

Can't help you there. None of my Arduino projects are that involved that multiple directories under the sketch directory are needed.


I believe the more recent arduino versions let you use a libraries folder in your sketchbook. Check the release notes.

Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview