Okay. I have created a folder in my libraries folder; it's named ACR. In it is a file, named ACR.h. For some reason, the IDE refuses to use that file. I can put the same file in my project folder, and it works. But I want the .h file to be visible to several projects, so cloning it, while possible, is foolish. Why does the IDE refuse to use the file in the ACR folder? What incantation have I missed. Yes, I restarted the IDE. Is there another key file of some form that must be present before the IDE will utilize ACR.h?
I'm sure it's just me, but the help info is opaque on this. "library must come in a zip", "unpack the zip to it's own folder within the libraries folder" means, to me, what I have done is equivalent.
Also, how does one ascertain what search order the IDE uses when looking for an include file? I thought it would be straightforward, like starting at the head of the libraries folder, but it seems to find older versions of my ACR.h file elsewhere, but does not see the one in the libraries\ACR\ folder once I've removed the others.
TIA
perplexed
done that a few times..
you have to add the lib to the ide..
zip up that folder, then in the ide you can add a library from zip..
which unzips to the library folder and some other magic..
Sketch->Include Library Add a zip is at the top..
As usual, just a few more words in the help system would be beneficial. Thanks.
There should be no need to zip anything up to add a library to the IDE. You have described the process that I have used multiple times
- create a folder in the Sketchbook/libraries folder with a name that exactly matches the name of the .h file
- copy the .h file of the library into the newly created folder
- copy the .cpp file of the library into the same folder
Job done
Sketches can now use the newly installed library using #include <LibraryName.h> or #include "LibraryName.h"
Exactly what was the error message that you got when you used this process and tried to #include the library in a sketch ?
What is the full path to your libraries folder ?
I'll be back to this in about an hour, Bob. By the way, this is NOT solved, I'll clear that flag.
Even though the information was not required to resolve the problem after all, I'll still share a link to the documentation of this system just in case you are interested in the boring details:
https://arduino.github.io/arduino-cli/latest/sketch-build-process/#dependency-resolution
All the Arduino documentation content is now hosted in public GitHub repositories where you are welcome to submit reports or proposals for corrections or improvements.
I was guessing that you were referring to the documentation here:
https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries#manual-installation
But I don't see the text you quoted there.
I found that for some reason there is another set of manual library installation instructions here:
But again I don't see the quoted text. So I guess there is some other set of instructions. If you post a link to where you found the documentation I can point you to the location of the source content where you can submit improvements if you like.
Thanks, I will follow up on this once my issue is sorted and I can actually include with confidence.
As for the quote, I'll check, and apologise if I paraphrased.
Some clarifications:
The name of the library dir and the enclosed file does not have to match. It is very common if library has name like ABCD.h and directory ABCD-master. As far I know the directory name can be completely diffrent from library name - it doesn't matter at all.
File .cpp is not required.
Have you tried that with any folder name other than one using the -master suffix ?
I know, but it is regarded as bad practice to put code in a .h file
Yes, just now
Lets create a library abcd.h
int abcd() {
Serial.print("GAGA");
}
Put it in directory, say, abcd-b707 in libraries folder and include our library in the sketch:
#include <abcd.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
abcd();
}
Try to compile:
Using library abcd-b707 in folder: T:\Arduino\libraries\abcd-b707 (legacy)
Sketch uses 1346 bytes (4%) of program storage space. Maximum is 30720 bytes.
Global variables use 190 bytes (9%) of dynamic memory, leaving 1858 bytes for local variables. Maximum is 2048 bytes.
Thanks, that is interesting
Either something has changed or I have always misunderstood
Moreover, it is not even necessary that the name of the library file and the name of the directory be even remotely similar. I named the library abсd.h and the folder abcd-b707. You could think that the library is visible because the starting portions of names are similar.
However, I can name the folder RTYU and it won't affect the visibility of the library:
sing library RTYU in folder: T:\Arduino\libraries\RTYU (legacy)
Sketch uses 1346 bytes (4%) of program storage space. Maximum is 30720 bytes.
Global variables use 190 bytes (9%) of dynamic memory, leaving 1858 bytes for local variables.
All very interesting, but flies in the face of my experience earlier.
libraries\ACR\acr.h was the file
#include <ACR.h> was the first line in my trivial sketch
Sketch was in my Arduino\Projects folder, where it always has been.
Doing the 'zip' thing, suggested earlier, made it work, but then it couldn't find the next include.
All of these include files have been being used in these sketches for months. Scratching my head, indeed.
I'll get the message when I'm down in the lab in a few minutes, but the message clearly stated it couldn't find ACR.h.
No idea what's going on. Restarted the IDE, no help. posted message, then got interrrupted. back at it soon.
C
If your file named as acr.h, your include MUST be
#include <acr.h>
Includes are case-sensitive in C/C++ !
My bad, typo, cases are consistent.
And, I'm now fighting another "missing" file. Auto485.h
- present in the libraries\Auto485 folder, as Auto485.h
-
#include <Auto485.h> is the line in the sketch
error message is Auto485.h: No such file or directory
Baffles me. This stuff was all happy and working yesterday. No doubt, something I did, but GOK what.
Clue
If I make a libraries folder within my projects folder (which holds all my sketch folders, so logically, the new libraries folder is 'beside' the test project's folder)
then the IDE finds the 'missing' files there. It doesn't seem to go back to the Arduino\libraries folder, but it's happy to go up one tier and find 'libraries' there.
Library help: https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries
Part way down
Importing a .zip Library
Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. Inside the folder will be a .cpp file, a .h file and often a keywords.txt file, examples folder, and other files required by the library. Starting with version 1.0.5, you can install 3rd party libraries in the IDE. Do not unzip the downloaded library, leave it as is.
In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to "Add .ZIP Library''.
You will be prompted to select the library you would like to add. Navigate to the .zip file's location and open it.
Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.
It was there in the list. But actually, no it wasn't expanded. The zip file had only ACR\ACR.h in it, perhaps it needs more? (I don't believe so, but I'm not getting anywhere).
Now, as to whether my "quoted text" was accurate or not, well, I'm sorry. But the gist was accurate.
Reading further,
Manual Installation
When you want to add a library manually, you need to download it as a ZIP file, expand it and put in the proper directory. The ZIP file contains all you need, including usage examples if the author has provided them. The library manager is designed to install this ZIP file automatically as explained in the former chapter, but there are cases where you may want to perform the installation process manually and put the library in the libraries folder of your sketchbook by yourself.
You can find or change the location of your sketchbook folder at File > Preferences > Sketchbook location.
Go to the directory where you have downloaded the ZIP file of the library
Extract the ZIP file with all its folder structure in a temporary folder, then select the main folder, that should have the library name
Copy it in the "libraries" folder inside your sketchbook.
Start the Arduino Software (IDE), go to Sketch > Include Library . Verify that the library you just added is available in the list.
Reading that last, I think if I have a file libraries\ACR\ACR.h, and I #include <ACR.h>, I should be done.
And I'm still looking for a solution. How does one force the IDE to review the libraries hierarchy to find the files that are in there? Because obviously, it needs a reminder. Restarting the IDE wasn't enough, Auto485.h, another in-existence file, can't be 'seen' by the IDE.
It works for me.
Did you read the post #10?
I created a folder under libraries, put the file abcd.h to it and add #include <abcd.h> in the sketch. It was enough for IDE to compile the code.
But that's exactly what I'm complaining about. I've done that for eons, and suddenly, my IDE barfs. If it were predictable, or if I could see what I've done wrong, fine, but it's there, I can see it, but my $%^&* IDE can't.
That restarting doesn't fix it tells me something's fudged in the IDE config, but there's nothing in preferences that gives me warm fuzzies about that.