Inclusion of subdirs in compilation with recent IDEs

I have a project that I distribute out in source code form and includes a number of prerequisite libraries. For the past few years I've had these included in the project directory under a subdir called 'libs' and the build instructions were to copy these into the arduino/libraries directory. This has worked fine for ages, certainly with IDEs as recent as 1.6.0, but now with more recent IDE versions (I think from 1.6.6, but I haven't checked each revision) this method no longer works.

it appears that these files are now being included in the compile path, despite being in a subdirectory of the project. If they have been copied to the arduino/libraries directory first (Which had always previously worked) then a duplicate declaration error is thrown for everythig in them. Eg:

Users/josh/Documents/Arduino/libraries/PID_v1/PID_v1.cpp:20: multiple definition of `PID::SetOutputLimits(double, double)'
/var/folders/p5/6x9sjnpj4n1djxp8_ycnqqym0000gn/T/buildf392b159bb6fff30aa45de7322c15428.tmp/sketch/libs/PID_v1/PID_v1.cpp.o:/var/folders/p5/6x9sjnpj4n1djxp8_ycnqqym0000gn/T/buildf392b159bb6fff30aa45de7322c15428.tmp/sketch/libs/PID_v1/PID_v1.cpp:20: first defined here

The temporary folder that this is being compiled from is now including the ./libs directory as highlighted.
If I remove the files from the arduino/libraries directory though, it fails to compile as it can't find the included .h files

I read through the changelog of each revision back to 1.6.0, but couldn't see anything specifically related to this. Does anyone know if this is an intended feature or not? If it is, has there been any recommended way of dealing with this type of situation at all?

This was an intentional change: Recusively copying additional files by ffissore · Pull Request #3435 · arduino/Arduino · GitHub as requested in Add sketch subdir in the Include Path · Issue #3080 · arduino/Arduino · GitHub

I see two ways of dealing with the change:

  • Change your installation instructions to say "move" instead of "copy".
  • Remove the instructions that says to copy the folders to the libraries folder and change the includes in the project to point to the files in the subfolder of the project where they are originally located. The problem with this is that it is not backwards compatible with IDE versions before arduino/3435 was merged and if the libraries are generally useful it's better to install them to the libraries folder so they can be accessed from any sketch.

Note: you're supposed to install 3rd party libraries to the {sketchbook}/libraries folder, not the libraries folder under the IDE folder, otherwise all the 3rd party libraries will be lost when you install a new version of the IDE.

Thank you so much!

I'll go with option 2, which had actually been my preference years ago, but obviously it wasn't possible back in the 0.9.x days. Option 1 had the additional problem that git would always complain on my local machine if I moved those files out etc, so being able to just use them from there is good.

I understand what you mean about these available across all projects if there is value to them, but it will also allow for customisations to be made to them without breaking other sketches, so pros and cons.

I am a little surprised that this didn't garner a mention in any of the changelogs (That I can see anyway) given it has the potential to break compilation, but these things can be easily missed I supposed.

Thank you once again!