Source: https://mokxi.com/errors/stm32f4xx-h-no-such-file-or-directory
Updated: 2026-11-16

Home / Errors
Arduino build error

# fatal error: stm32f4xx.h: No such file or directory

stm32f4xx.h and the stm32f4xx_hal headers belong to ST's HAL, the library that STM32CubeIDE projects call. They exist on STM32 F4 boards only.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes

The message

## What the Arduino IDE prints

Output window

Include it on an Uno, or include the header of another STM32 family, and the compiler cannot find the file.

Mokxi's compiler, clang, words it as 'stm32f4xx.h' file not found.

Causes

## The 2 usual causes with the fix

### 1The board is not an STM32

Choose an STM32 F4 board, such as the Black Pill (F411) or the Nucleo-F411RE, and include stm32f4xx_hal.h. Mokxi has the HAL for both.

Broken

Fixed

Mokxi’s build tab says: stm32f4xx.h is for boards that have it: the STM32 Nucleo-F411RE and the STM32 Black Pill (STM32F411).

Try this fix in Mokxi

### 2The header is for another STM32 family

The F1 Blue Pill uses stm32f1xx_hal.h and the F4 boards use stm32f4xx_hal.h. A header copied from a Blue Pill project fails on a Black Pill, and the reverse.

Broken

Fixed

Mokxi’s build tab says: stm32f1xx_hal.h is for boards that have it: the STM32 Blue Pill (STM32F103).

Try this fix in Mokxi

FAQ

## Questions and answers

### What is the STM32 HAL?

ST's hardware abstraction layer: the C functions that STM32CubeIDE projects use to drive pins and peripherals.

### Can I use the HAL on an Arduino Uno?

No. The Uno has an AVR chip, and the HAL is written for ST chips. Use pinMode and digitalWrite there.

### Do I have to use the HAL on an STM32 board?

No. The Arduino calls such as pinMode, digitalWrite and analogRead work on STM32 boards too, and are simpler.

Next

## More errors and the longer guide

- fatal error: Servo.h: No such file or directory
- fatal error: WiFi.h: No such file or directory

The longer guide to this error All Arduino errors
