fatal error: …h: No such file or directory

  • Arduino
  • ESP32
  • ESP8266

You may see

fatal error: SevSeg.h: No such file or directory
fatal error: MQ2.h: No such file or directory
fatal error: Adafruit_TCS34725.h: No such file or directory
fatal error: DHT.h: No such file or directory
fatal error: LiquidCrystal_I2C.h: No such file or directory
fatal error: MFRC522.h: No such file or directory
fatal error: Firebase_ESP_Client.h: No such file or directory
compilation terminated.

Why it happens

  • The library isn't installed on this computer.
  • The name is spelt differently. Capitals matter on Linux and Mac.

How to fix it

  1. Read the .h name in the message.
  2. Open Tools > Manage Libraries (Arduino IDE 2: the books icon), search for the name and press Install.
  3. If it offers to install other libraries too, choose Install all.
  4. If the lesson gives a .zip file, use Sketch > Include Library > Add .ZIP Library.
  5. Press Verify again.

It worked if: The red line about that .h file is gone.

Seen in a real run (some lines are close variants of it). Produced with Arduino CLI 1.5.1 and Arduino AVR core 1.8.8 (the same compiler the Arduino IDE uses). Most of these came from compiling our own lessons on a computer without the library.

Didn't help? Search another error or ask us.