How to Fix stdio.h Not Found on Linux

Installing stdio.h On Linux

The error fatal error: stdio.h: No such file or directory means the compiler cannot find the C standard library headers for the toolchain it is using. On Linux, fix the development package or compiler configuration instead of downloading a standalone stdio.h file.

Confirm the compiler failure

Start with a small program. This separates a missing system header from an editor diagnostic, a cross-compiler sysroot issue, or a project include-path mistake.

#include <stdio.h>

int main(void) {
    puts("stdio.h is available");
    return 0;
}

Save it as stdio-check.c, then compile and run it from the same directory.

gcc -Wall -Wextra -o stdio-check stdio-check.c && ./stdio-check
GCC compiles and runs a C program that includes stdio.h
A successful compile and run confirms that the compiler can resolve stdio.h.

I compiled this exact source with GCC 14.2.0 on Debian, and the output stdio.h is available confirms that the compiler resolved the header through its configured system search directories.

Install the C development package for your distribution

stdio.h ships with the C library development files supplied by your distribution, so install the matching package family and rerun the compile command above.

Distribution familyCommandWhat it supplies
Debian and Ubuntusudo apt install build-essential libc6-devGCC, build tools, and glibc headers
Fedorasudo dnf install gcc glibc-headers glibc-develGCC and glibc development headers
RHEL-compatible systemssudo dnf group install “Development Tools”The compiler toolchain group
Alpinesudo apk add build-base libc-devBuild tools and musl development headers
Arch Linuxsudo pacman -S base-develBase compiler and build tool collection

On Debian, libc6-dev owns /usr/include/stdio.h. If the compiler is absent, follow the GCC installation steps for Debian and Ubuntu before troubleshooting include paths.

Check where GCC searches for headers

A native GCC install searches its configured system directories for angle-bracket headers. Print that list before adding -I flags, because -I is for a project dependency and does not repair a broken standard-library installation.

gcc -E -x c - -v < /dev/null

Look for the section headed #include <…> search starts here. A native Debian GCC installation includes /usr/include in that list. If stdio.h exists there but GCC does not search it, inspect the compiler command selected by your build system.

Fix the case that matches your build

The package command fixes a native toolchain that lacks development headers. Other failures need a narrower fix.

  1. If GCC compiles the check program but your editor reports stdio.h missing, configure the editor to use the same compiler or compile_commands.json file.
  2. If you use a cross compiler, install the target sysroot and pass the sysroot supplied by that toolchain. Your host’s /usr/include directory is not the target C library.
  3. If one project fails, inspect its compiler invocation for -nostdinc or an incorrect –sysroot value.

Once the base compile succeeds, move to running C programs from the Linux terminal for a full source-to-binary workflow. A threaded program needs the same development environment plus GCC’s -pthread option, covered in this POSIX threads compilation guide.

Verify the repaired toolchain

Use this checklist before returning to a larger project.

  • gcc –version returns the compiler you expect.
  • The stdio-check.c command completes and prints its message.
  • Your editor and build system invoke that same compiler.
  • A cross build has a target sysroot with its own C library headers.

For command-line navigation and package inspection, keep the Linux command line reference nearby. On Red Hat systems that also build C++ projects, the G++ setup guide for Red Hat covers the adjacent compiler workflow.

Can I download stdio.h by itself?

No. stdio.h must match the C library and compiler toolchain on your system. Install the distribution development package instead of copying a header from another machine.

Why does GCC find stdio.h but my editor does not?

Your editor may use a different compiler path or an incomplete include-path configuration. Point its C language tooling at the compiler or build database that compiles the project successfully.

Does -I fix a missing stdio.h error?

Use -I for project headers. A missing standard header usually means that the compiler, sysroot, or C library development package needs repair.

When the small check compiles, keep the compiler invocation it used. That command is the reference point for repairing the editor or build configuration that still cannot resolve stdio.h.