Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

Fix “fatal error: XYZ.h: No such file or directory”

The sketch includes a library header that is not installed, or under a different name. Install the right library from Library Manager.

All boardsUpdated 31 Oct 2026

Community draft — report a mistake

What you see

OutputOutput
sketch.ino:3:10: fatal error: DHT.h: No such file or directory
    3 | #include <DHT.h>
      |          ^~~~~~~
compilation terminated.
exit status 1

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

The compiler could not find the header file named in an #include line. It is almost always a library that has not been installed yet — the fix takes a minute in Library Manager.

Every FlashReady code block lists the library and version it was compiled with, so you can install exactly that one.

Quick fix — try in order

  1. 1

    Install the library

    Sketch → Include Library → Manage Libraries, search the header name or library name (e.g. “DHT sensor library” by Adafruit), click Install.

  2. 2

    Install its dependencies too

    Arduino IDE 2 offers “Install all”. Adafruit sensor libraries also need “Adafruit Unified Sensor”.

  3. 3

    Match the header name exactly

    LiquidCrystal_I2C.h, not LiquidCrystal_l2c.h. Case matters on macOS and Linux.

  4. 4

    Check it supports your board

    Some libraries are AVR-only. The Library Manager entry lists supported architectures.

Why it happens

Many libraries share a header name

Several “LiquidCrystal I2C” libraries exist with different APIs. Our pages state the exact library and version used to compile; installing a different one can cause other errors such as does not name a type.

Library in the wrong folder

Manually downloaded ZIPs must go in Documents/Arduino/libraries/<LibraryName>/ with the .h file at the top level (or in src/).

Board package library missing

WiFi.h, BluetoothSerial.h and similar come with the board package — select the right board (e.g. ESP32 Dev Module), not Arduino Uno.

Board-specific notes

ESP32 vs ESP8266: ESP8266 sketches use ESP8266WiFi.h; ESP32 uses WiFi.h. Selecting the wrong board gives this error for the Wi-Fi header.

Parts: DHT22 · 16×2 I2C LCD — pinout, voltage and library notes.

↑↓ to move · Enter to open