Compilation of "Keypad" library example fails: "Key.h: No such file or directory"

C:\Users\Hoang Tung\OneDrive\Tài liệu\Arduino\libraries\Keypad\examples\CustomKeypad\Key.cpp:30:10: fatal error: Key.h: No such file or directory
compilation terminated.
exit status 1

Compilation error: exit status 1

Hi @panthe. Unfortunately there is a bug in the sketch compiler that causes it to fail to find the library when it is installed under a path that contains this sort of character:

The presence of such characters in the path is more likely to occur because Microsoft OneDrive automatically uses the localized name for the Windows Documents folder based on your system locale.

The workaround will be to configure Arduino IDE to use a different path to store libraries. I'll provide instructions you can follow to do that:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Click the "BROWSE" button on the right side of the "Sketchbook location" field.
    The "Select a new sketchbook location" dialog will open.
  3. Select a folder in any location that contains only basic ASCII characters (the characters A-z, 0-9, _, -, . are safe).
    :warning: Make sure to pick a location that will be safe to store your files since, in addition to containing installed libraries, the sketchbook is a convenient location to save your sketches.
  4. Click the "Choose" button in the "Select a new sketchbook location" dialog.
  5. Click the "OK" button in the "Preferences" dialog.
  6. Move all the files from the folder at the path of the old sketchbook location:
    C:\Users\Hoang Tung\OneDrive\Tài liệu\Arduino
    
    to the folder at the path of the new sketchbook location you set in the Arduino IDE preferences.

Once you have finished performing the instructions above, try compiling your sketch again. Hopefully the compilation will be successful this time.

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