Library no longer found

I've been working on this sketch for a few days with no compilation problems. I created a v2 by saving the sketch under "name2" in a subdirectory of where the original is saved. Now both v2 and the original throw the following error when compiling:

D:\xxx\Documents\Battery conditioner\Code\Final\Final2\Final2.ino:1:10: fatal error: Adafruit_GFX.h: No such file or directory
 #include <Adafruit_GFX.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: Adafruit_GFX.h: No such file or directory

Here's the start of my sketch:

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <EEPROM.h>
#include "RTClib.h"

I've confirmed Adafruit_GFX.h exists in several places on my PC, including a Libraries folder I just created in the same sub-folder as the sketch in question. Any idea what I might have borked, and how to unbork it? Thanks.

Hi @Involute.

Did you change the value of Arduino IDE's "Sketchbook location" preference (the preferences are accessed via Arduino IDE's File > Preferences menu item)?

The globally installed libraries are installed under the libraries subfolder of the sketchbook folder, so if you change the "Sketchbook location" preference, then Arduino IDE will no longer be able to find the libraries you installed at the time you had a different "Sketchbook location" preference value.

The most simple way would be to install the library again:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
  2. Type Adafruit GFX Library in the "Filter your search..." field.
  3. Find the "Adafruit GFX Library" entry in the list of search results.
  4. You will see an "INSTALL" button at the bottom of the entry. Click the button.
    An "Install library dependencies" dialog will open.
  5. Click the "INSTALL ALL" button in the "Install library dependencies" dialog.
    The dialog will close.
  6. Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:

    ⓘ Successfully installed library ...

After doing that, try compiling your sketch again. Hopefully this time the "Adafruit_GFX.h: No such file or directory" will not occur.

1 Like

Your sketchbook directory should look like this

sketchbook
|
+--- yourProject
|    |
|    +--- yourProject.ino
|
+--- yourProjectV2
|    |
|    +--- yourProjectV2.ino

where sketchbook is the directory specified under file → preferences.

I suspect that your sketchbook directory now looks like

sketchbook
|
+--- yourProject
|    |
|    +--- yourProject.ino
|    |
|    +--- yourProjectV2
|    |    |
|    |    +--- yourProjectV2.ino

I'm not sure of the side-effects of the latter.

Adding the AdaFruit_GFX (and any other library) under yourProjectV2 is a futile exercise. The IDE looks in very specific locations and yourProjectV2 is not one of them.

Delete the yourProjectV2 directory.

Thanks, ptillisch and sterretje. Followed your advice and everything's back to normal (except FTDI uploading problems for which I've created a new post).

2 Likes

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