All the current libraries that I use are in the following directory: /home/graham/Arduino/arduino-1.8.9/libraries
I have created a directory called DateTime
In this I have a sub directory called src
In this I have two files: DateTime.cpp and DateTime.h containing source code.
I now start an empty sketch:
I get the error: DateTime.h: No such file or directory (On both include options!)
I also have another directory called: /home/graham/Arduino/arduino-nightly/libraries/DateTime where I have put the source files.
And another called /home/graham/sketchbook/libraries/DateTime
All to no avail.
Where and how should the library be created?
Any help would be much appreciated.
GrahamB
There is no need to specify the full path of the library. One reason is that it causes your code to be non-portable. The other reason is that the Arduino IDE will only do compilation of the libraries that are installed to the correct location, where no full path is required. The full path will work if you only need to include a .h file, but the other source files in the library will not be compiled as you might expect.
GrahamB1941:
Where and how should the library be created?
Always install libraries to the libraries subfolder of your sketchbook folder. You can find the location of your sketchbook folder in the Arduino IDE at File > Preferences > Sketchbook location.
Each library should be in its own folder directly under the libraries folder. There are two different Arduino library formats: 1.0 and 1.5, as described in the Arduino library specification:
If your library is in the 1.0 format, it would look like this:
Karma_1986
Thank you for your quick response.
I appreciate that one does not include full paths in header files. It was to see if the sketch found it. It didn't.
My home/sketch/libraries/ tree looks like this:
I note that your format shows directories and files starting with a lower case l followed by an underscore (l_). Is this intentional?
I still have the problem:- DateTime.h: No such file or directory
Incidentally I am using Linux Mint.
Thank you again for your assistance.
Is home/sketch your sketchbook folder, as shown in File > Preferences > Sketchbook location?
What does the "- examples" part mean?
You say "My home/sketch/libraries/ tree", but then your diagram shows a libraries folder. So is the path to DateTime.h home/sketch/libraries/libraries/DateTime/DateTime.h?
GrahamB1941:
I note that your format shows directories and files starting with a lower case l followed by an underscore (l_). Is this intentional?
No! The "|_" is the way I indicate the folder tree, just as you used "└── ". It's not part of the folder names and filenames.