Pages: [1]   Go Down
Author Topic: possible to #include files outside /libraries and sketch folder ?  (Read 401 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

Say I have three Arduino sketches that all rely on the same library or libraries.  I am actively working on both the .INOs and the libraries, and its a ton of code, so they need to be tightly synced on Github.  Putting the libraries in the Arduino/libraries folder and using two or more separate repositories is going to get messy and disorganized fast.  So the file structure should be something like:

/main/SharedClass.h
/main/SharedClass.cpp
/main/Sketch1/Sketch1.ino
/main/Sketch2/Sketch2.ino
/main/Sketch3/Sketch3.ino

How do I include SharedClass.h in my sketches?  #include "../SharedClass.h" doesn't seem to work. 

Any thoughts?  Is there a straightforward solution here?  How are people organizing their similar projects?  Any help is appreciated.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I'm very much a classless knowledgeable software type (bad pun?), but might one be able to add the class .h and .cpp stuff into tabbed sections of the user's sketch that you don't want to have included from the common users library?

Lefty
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

had a similar problem, apparently you need to add:

Code:
#include "Arduino.h"

to you header files.
Logged

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I'm very much a classless knowledgeable software type (bad pun?), but might one be able to add the class .h and .cpp stuff into tabbed sections of the user's sketch that you don't want to have included from the common users library?

Thanks, but I'm not 100% sure I'm following.  Are you suggesting I add the class files into each sketch?  If I did that, I would have to copy and paste the most recent files into every sketch folder every time I wanted to compile, which would be messy and cumbersome.  If I missed your point, please do clarify, I really would like to figure this out...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

had a similar problem, apparently you need to add:

Code:
#include "Arduino.h"

to you header files.

Hey thanks for responding.  Can you confirm you actually have this working?  I actually already have #include "Arduino.h" in all my header files. 

Just to be clear, you're saying that, as in my example in the first post, adding #include "Arduino.h" to SharedClass.h will allow it to be included to Sketch1.ino with #include "../SharedClass.h" ?  Unless I'm missing something else, that isn't working for me...
Logged

Pages: [1]   Go Up
Jump to: