Compile Error: TFT Can't Find SD Library

SD Library Path
C:\Users\15172\Documents\Arduino\libraries\SD

TFT Library Path
C:\Users\15172\Documents\Arduino\libraries\TFT

Adafruit_GFX.h path
C:\Users\15172\Documents\Arduino\libraries\TFT\src\utility

Warning SD library was not found?
GFX.h line 57-61
#if defined(SD_H) // Arduino SD library <<<<<<<<<<<<<<<<<<<,
#include "PImage.h"
#else
#warning "The SD library was not found. loadImage() and image() won't be supported."
#endif

How to fix this???
Thanks
Robert

Which Arduino board are you using ?
Please post the sketch that you are using

Uno R3

In file included from c:\Users\15172\Documents\Arduino\libraries\TFT\src/TFT.h:36:0,
from C:\Users\15172\Documents\Arduino\libraries\TFT\examples\Arduino\TFTGraph\TFTGraph.ino:16:
c:\Users\15172\Documents\Arduino\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."
^~~~~~~

 TFT Graph

 This example for an Arduino screen reads
 the value of an analog sensor on A0, and
 graphs the values on the screen.

 This example code is in the public domain.

 Created 15 April 2013 by Scott Fitzgerald

 http://www.arduino.cc/en/Tutorial/TFTGraph

 */
#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1

TFT TFTscreen = TFT(cs, dc, rst);

// position of the line on screen
int xPos = 0;

void setup() {
  // initialize the serial port
  Serial.begin(9600);

  // initialize the display
  TFTscreen.begin();

  // clear the screen with a pretty color
  TFTscreen.background(250, 16, 200);
}

void loop() {
  // read the sensor and map it to the screen height
  int sensor = analogRead(A0);
  int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height());

  // print out the height to the serial monitor
  Serial.println(drawHeight);

  // draw a line in a nice color
  TFTscreen.stroke(250, 180, 10);
  TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height());

  // if the graph has reached the screen edge
  // erase the screen and start again
  if (xPos >= 160) {
    xPos = 0;
    TFTscreen.background(250, 16, 200);
  } else {
    // increment the horizontal position:
    xPos++;
  }

  delay(16);
}


Have you looked at the Adafruit_GFX.h file that the waring emanates from ?

/*
 * This library can work with or without the presence of an SD
 * reading library (to load images). At the moment, only the
 * Arduino SD library is supported; it is included in
 * standard Arduino libraries.
 * 
 * The presence of the SD library is detected by looking at the
 * __SD_H__ preprocessor variable, defined into 
 * Arduino SD library to avoid double inclusion. This means
 * that in order to use the image-related API of Adafruit_GFX,
 * SD.h *must* be included before Adafruit_GFX.
 * 
 * The bottom part of this include file contains the actual image
 * loading code; if it was in a separate .cpp file, there were no
 * way to check if the SD library was present or not.
 * 
 * A partial solution was to include SD.h anyway, see if that works
 * (i.e. it is found in the include search path) and act accordingly.
 * But this solution relied on the preprocessor to issue only a
 * warning when an include file is not found. Avr-gcc, used for
 * Arduino 8-bit MCUs, does that, but the standard gcc-4.4, used for
 * Arduino Due, issues a fatal error and stops compilation.
 * 
 * The best solution so far is to put the code here. It works if this
 * include is used only in one .cpp file in the build (this is the
 * case of most Arduino sketches); if used in multiple .cpp files,
 * the linker may complain about duplicate definitions.
 * 
 */

Yes. I hd posted that warning in my original message: #if defined(SD_H) // Arduino SD library #include "PImage.h" #else #warning "The SD library was not found. loadImage() and image() won't be supported." <<<<<<<<<<<<<<<<<<<<<<<<<< #endif

So do you have a problem or not ?

The full quote that I posted includes a workaround if you need to use loadimage() or image() but it is not clear to me whether you need them or not. If not, then just ignore the warning

Consider including the SD library.

I did, did not work. Both SD and SDFat are in repository
C:\Users\15172\source\repos

Obviously that path must be on built in search path.
Robert

The SD library is by default in the correct folder when you install the Arduino IDE, so what happened to it?

But, you can also put the library in other places where the IDE expects to find it. One such a possibility is the Arduino sketch folder "libraries" subfolder.

I though the repos was the default folder?

I don't know what you mean by "repos".

The Arduino IDE must be installed properly, and that process will create other folders.

It is there C:\Users\15172\Documents\Arduino\libraries\SD

Post the code, using code tags, showing how you tried to include the SD library.

Repositories

When I clone stuff on github I am using Visual C++ which outs it here:
C:\Users\15172\Source\Repos

No compile errors now:
Robert

TFT Graph

This example for an Arduino screen reads
the value of an analog sensor on A0, and
graphs the values on the screen.

This example code is in the public domain.

Created 15 April 2013 by Scott Fitzgerald

http://www.arduino.cc/en/Tutorial/TFTGraph

*/

#include <SD.h>  //<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

Why doesn't the site use the std code /code?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.