In the code below i am trying to give the full path of SD.h file to the compiler, to avoid it saying "Found mutiple files blah blah "
And yet it gets angry and says Fatal Error ... no such file of directory. Why is that ?
I do know that providing the full path is a bad idea as it makes the code not portable. But then there are times when the compiler insists >:( to use a specific header from the many and even when that header is useless.
( Using IDE 1.8.5 on a WIN10 laptop)
#include <SPI.h>
//#include <SD.h> Commented out for trial...
#include "C:\Users\ragun\Documents\Arduino\libraries\SD\SD.h"
File myFile;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
}
void loop() {
// nothing happens after setup finishes.
}
Hmmmm... reason for not removing duplicate libraries...No i dont have a reason except that i am scared.
Yes this mess up came around when i installed Teensyduino for using the Teensy3.5. So i have one full library for Teensy. Then AVR has its folder of libraries. Like in my case see how many SD.h exist :
Multiple libraries were found for "SD.h"
Used: C:\Users\ragun\Documents\Arduino\libraries\SD
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Ok in this case atleast it has used the library in my sketch folder. In some cases it will use from wherever it wants... and the code does not compile. Like the Teensy boards are happy with only the Wire.h of PJRC. Not the regular Wire.h
Actually i have been reading about how this library files are handled by the AVR compiler ... lookslike its a complex subject not for the weak in heart.
Ardubit:
And yet it gets angry and says Fatal Error ... no such file of directory.
It says much more than that. By paraphrasing the error message you only reduce your chances of getting help. Maybe you don't know how to copy and paste? If so, time to learn. This is an essential skill for a computer user. The Arduino IDE even makes it easier by providing you a helpful button on the right side of the orange bar "Copy error messages".
On my system I get this error message:
E:\electronics\arduino\libraries\SD\src\SD.h:20:27: fatal error: utility/SdFat.h: No such file or directory
The extra information provided by the error message is crucial in this case. When I look at the problematic line 20 of SD.h I find this:
#include <utility/SdFat.h>
This is a very common bug in Arduino libraries: Incorrect #include directive syntax. The reason why it's so common is that it doesn't cause any problems when the library is used normally. The angle brackets syntax causes the include path to be searched for the file. But in your usage the file is not found in the include path. The correct double quotes syntax causes the local folder to be searched before the include path. Changing to the correct #include directive syntax fixes the problem. This is why it's important to understand what each syntax does and always use the correct one. I have submitted a pull request to fix this bug in the SD library:
Are you sure that's the correct path? If you're using a recent version of the official SD library the path should be C:\Users\ragun\Documents\Arduino\libraries\SD**src**SD.h. Again, so crucial to provide the full error output when asking for help here.
Multiple libraries were found for "SPI.h"
Used: C:\Users\ragun\Documents\Arduino\libraries\SPI
C:\Users\ragun\AppData\Local\Temp\arduino_modified_sketch_623816\Files.ino:22:62: fatal error: C:\Users\ragun\Documents\Arduino\libraries\SD\SD.h: No such file or directory
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
compilation terminated.
Using library SPI at version 1.0 in folder: C:\Users\ragun\Documents\Arduino\libraries\SPI
Error compiling for board Teensy 3.5.
pert:
Are you sure that's the correct path? If you're using a recent version of the official SD library the path should be C:\Users\ragun\Documents\Arduino\libraries\SD**src**SD.h.
Not sure why the forum wouldn't copy your reply (probably because it shouldn't have been in quote tags, since you weren't quoting anything), but
C:\Users\ragun\Documents\Arduino\libraries looks like the path where user downloaded libraries go. The SD library should NOT be in the user downloaded libraries folder.
Ye seven i thought its going to be a Eureka moment as indeed the path i gave WAS wrong.
But then even after correcting it , it keeps searching for the ../utility/SdFat.h file.
Aside from all of this is there no way to specifically tell the Compiler to use the exact header file and maybe include it in the sketch folder itself. This will of course rob the compactness of the sketch folder and also make you miss updates to the central repository. But then its a easy way to share the sketch which uses some exotic libraries.
I was quoting part of my original reply. The reason why I did that is because apparently Ardubit ignored it the first time around.
PaulS:
The SD library should NOT be in the user downloaded libraries folder.
That's where Library Manager installs libraries to. When Arduino releases a new version of one of their libraries you get an updatable library notification and when you do the update the result is you having an official library in the libraries subfolder of the sketchbook. So these days this is a quite normal situation. I don't like Library Manager's pollution of the sketchbook and tried to get Arduino to rethink that decision but for some reason they were very set on doing it this way.
Ardubit:
But then even after correcting it , it keeps searching for the ../utility/SdFat.h file.
There you go again with not posting the full error message.
Ardubit:
is there no way to specifically tell the Compiler to use the exact header file and maybe include it in the sketch folder itself.
Then the #include directive in SomeSketch.ino would look like this:
#include "src/SD/SD.h"
You must put the bundled libraries under the src subfolder, though you can have any folder structure you like within the src folder. The Arduino IDE has a special treatment of the src subfolder of the sketch.
You will run into the problem with the incorrect #include directive syntax with this approach as well, but that's easily fixed.
This gets a bit more messy if you have one bundled library that depends on another bundled library. In that case you would need to make the #include directives for the dependency relative.
pert:
Not sure why the forum wouldn't copy your reply (probably because it shouldn't have been in quote tags, since you weren't quoting anything), but
C:\Users\ragun\Documents\Arduino\libraries looks like the path where user downloaded libraries go. The SD library should NOT be in the user downloaded libraries folder.
You are right Paul about the location of user downloaded library. Yes its my work to copy all essential libraries in one point and have that as my single central library. May be i should completely knock off the IDE installation and do a fresh one and avoid copying the native libraries to it ? Will that help in anyway ?
Well i did a search for SPI.h to see in how many places it was there. To be honest i am zapped. Its almost two screenful of locations. Just see the screen shot attachments. Is this kind of normal or i have a very messed up IDE installation ?
But only three locations actually matter and the Arduino IDE already told you about them:
Ardubit:
Multiple libraries were found for "SD.h"
Used: C:\Users\ragun\Documents\Arduino\libraries\SD
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Those are the three in the include path.
The library you want is being used. I've already explained how you can specify a specific library two different ways. It seems like you're just getting all freaked out by a helpful informational message the Arduino IDE provides. The selection of which library to use when multiple are found is not random. There are several factors the Arduino IDE uses to determine which library to use. In most cases (including this one) it picks the right one. In case it didn't pick the right one, it tells you which it used and which it didn't use. I won't bother to explain the include priority factors because, based on our conversation so far, it's not clear to me that you actually want my help or would even bother to read what I wrote.
My advice is to stop worrying about this until such time as the Arduino IDE chooses incorrectly. When that happens, come back to the forum and we'll help you resolve the problem.
even after correcting it , it keeps searching for the ../utility/SdFat.h file.
When you put a "#include <SD.h>" statement in your Arduino sketch, that not only causes the compiler to include that file from the library it finds, but ALSO causes the IDE to recognize that "SD" is the name of a standard libary, and add a number of search paths to the compile command to properly search all of the standard "library sub-directories" associated with an Arduino library.
If you specify an absolute path to a particular include file, the IDE can't figure out that it's part of an arduino library, doesn't add the additional search paths, and you get the sort of error that you're seeing.
pert:
But only three locations actually matter and the Arduino IDE already told you about them:Those are the three in the include path.
The library you want is being used. I've already explained how you can specify a specific library two different ways. It seems like you're just getting all freaked out by a helpful informational message the Arduino IDE provides. The selection of which library to use when multiple are found is not random. There are several factors the Arduino IDE uses to determine which library to use. In most cases (including this one) it picks the right one. In case it didn't pick the right one, it tells you which it used and which it didn't use. I won't bother to explain the include priority factors because, based on our conversation so far, it's not clear to me that you actually want my help or would even bother to read what I wrote.
My advice is to stop worrying about this until such time as the Arduino IDE chooses incorrectly. When that happens, come back to the forum and we'll help you resolve the problem.
Ardunio. File paths. Errors. All can wait.
First I want to thank you for the support that you gave and assure that every bit of what you wrote is consumed. Possibly that did not reflect in my responses. But then compared to your level of knowledge on these things I am just at the entry post .. so its difficult to engage one on one. Sorry about that.
And incidenatlly the one suggestion that helped most is to copy the error message, paste it in Notepad and read the full story. Otherwise its a small window at the bottom you scroll and miss the important. My issue got resolved and the proof is this :
Using library LiquidCrystal in folder: C:\Users\ragun\Documents\Arduino\libraries\LiquidCrystal (legacy)
Using library phi_interfaces in folder: C:\Users\ragun\Documents\Arduino\libraries\phi_interfaces (legacy)
Using library RunningAverage in folder: C:\Users\ragun\Documents\Arduino\libraries\RunningAverage (legacy)
Using library SD at version 1.2.2 in folder: C:\Users\ragun\Documents\Arduino\libraries\SD
Using library Wire at version 1.0 in folder: C:\Users\ragun\Documents\Arduino\libraries\Wire
Using library EEPROM at version 2.0 in folder: C:\Users\ragun\Documents\Arduino\libraries\EEPROM
Using library Time-master at version 1.5 in folder: C:\Users\ragun\Documents\Arduino\libraries\Time-master
Using library SPI at version 1.0 in folder: C:\Users\ragun\Documents\Arduino\libraries\SPI
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-size" -A "C:\\Users\\ragun\\AppData\\Local\\Temp\\arduino_build_149566/Teensy3.5_DataLogger_V1.0.ino.elf"
Sketch uses 58760 bytes (11%) of program storage space. Maximum is 524288 bytes.
Global variables use 7112 bytes (2%) of dynamic memory, leaving 255024 bytes for local variables. Maximum is 262136 bytes.
Finally if there is any link to a document on the priority factors that the IDE uses to choose libraries will be glad to get it. Thanks