The SD Library was not found!

Problem occurs when I compile following codes

#include <SD.h>
#include <TFT.h>
#include <SPI.h>

void setup() {
  
}

void loop() {

}

And IDE outputs following message
In file included from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/TFT.h:36:0,
from /Users/Mike/Desktop/arduino/sketch_jul03a/sketch_jul03a.ino:2:
/Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h: In static member function 'static PImage PImage::loadImage(const char*)':
/Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h:318:40: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]
if ((bmpFile = SD.open(fileName)) == NULL) {
^
In file included from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/TFT.h:36:0,
from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/TFT.cpp:32:
/Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h:60:3: warning: #warning "The SD library was not found. loadImage() and image() won't be supported." [-Wcpp]
#warning "The SD library was not found. loadImage() and image() won't be supported."
^
In file included from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.cpp:34:0:
/Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h:60:3: warning: #warning "The SD library was not found. loadImage() and image() won't be supported." [-Wcpp]
#warning "The SD library was not found. loadImage() and image() won't be supported."
^
In file included from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_ST7735.h:28:0,
from /Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_ST7735.cpp:19:
/Users/Mike/Downloads/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h:60:3: warning: #warning "The SD library was not found. loadImage() and image() won't be supported." [-Wcpp]
#warning "The SD library was not found. loadImage() and image() won't be supported."
^

I've checked IDE library management, the SD library was installed. so I don't know why, is this a bug? Anyone who can help me will be appreciated!

Please do this:

  • File > Preferences > Show verbose output during: > compilation (check) > OK
  • Sketch > Compile/verify
  • Wait for the compilation process to complete
  • Select all the output in the black console window at the bottom of the Arduino IDE window (it will be more that fits in the window at the default size.
  • Paste the output in a reply here USING CODE TAGS (</> button on the toolbar).

What do you have selected in the Tools > Board menu?

Which version of the Arduino IDE are you using?

Ok, actually I went ahead and tried it myself and I can reproduce the issue. This has already been reported to the developers:

but unfortunately there has been no response after 1.5 years.

Here's the problem: Adafruit_GFX.h checks if the SD library include guard macro has been defined and if it wasn't then it doesn't include PImage.h and it displays that warning (TFT/Adafruit_GFX.h at 1.0.5 · arduino-libraries/TFT · GitHub). What threw me off is that you had included SD.h in your sketch before including TFT.h so that macro should be defined. However, I forgot that Adafruit_GFX.h is also included from Adafruit_GFX.cpp and Adafruit_ST7735.cpp, which are separate compilation units and therefore don't have that macro defined.

So I don't know whether that means that the warning is spurious or if those two function will indeed not be available. It's worth a test to see which is the case. Regardless, that issue should certainly be fixed in the TFT library.

very strange, the codes has been compiled just now, what happened? I didn't make any changes.

The libraries are cached so you will only see the warnings on the first compilation. If you switch to a different board in the Tools > Board menu or restart the IDE you'll see them again.