How to fix Alpine Linux fatal error: stdio.h: No such file or directory

Problem:

When trying to compile a C/C++ program or library on Alpine Linux, you see an error message like

example.txt
/home/user/test.cpp:5:10: fatal error: stdio.h: No such file or directory
  123 | #include <stdio.h>
      |          ^~~~~~~~~

Solution

Install the libc headers using

example.sh
apk add musl-dev

 


Check out similar posts by category: Alpine Linux, C/C++, GCC Errors, Linux