How can two sketches share the same (local-to-the-sketches) files?

I have a project that looks something like this:


Part1 employs CommonFile1-3 and Part2 employs CommonFile2-4, for the most part.

What's infuriating to me is that the IDE creates COPIES of these files when I add them to the Part1 and Part2 sketches, which means that any edits I make within the IDE have to be manually copied from Part1 to Part2.... AND back to the original location?

How the hell do I get this thing to just open those files in place so I can edit THE file just once, instead of editing A file somewhere and copying it all over hell and gone? It would be idiotic to break this into three separate libraries to work around the deficiencies of my IDE. The groupings would fly in the face of any sensible encapsulation of the functions of the common components.

in your sketchbook folder in libraries subfolder create a folder with the name of the 'library' and put the files there.

I added them as a library (/TwoPartProject/libraries/TheLibraryName), and the arduino IDE copied all the files in the library to /TwoPartProject/Part1 and /TwoPartProject/Part2, which is what I'm trying to avoid.

Why did you do that instead of

The "Sketchbook Folder" - or rather, "Sketchbook Folders" are /TwoPartProject/Part1 and /TwoPartProject/Part2. Putting the files in question into a libraries subfolder of the sketchbook folders - plural - is going back to having multiple copies of each of the .h and .cpp files, which is exactly what I'm trying to avoid.

You only have one sketchbook folder. It is the folder where the folders for your sketches are located. Take a look in File/Preferences to see its exact location

The 'Sketchbook location' you see in preferences does not necessarily mean the place where your sketches are. 'Sketchbook location' is the default location for the sketch folders. And 'libraries' is a subfolder of 'Sketchbook location'. Libraries must be located there, no matter where your personal sketch folder is.

sorry 'a sketch' is a folder. sketchbook is a folder with sketches. default is Documents/Arduino.

@foodini Installation and Troubleshooting is for Problems with the Arduino itself NOT your project. It says so in the description of the section. Therefore I have moved your post here.

You may want to read this before you proceed:-
how to get the best out of this forum

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.