`fatal error: stdio.h: No such file or directory` is a frustrating result when `gcc` itself answers in the terminal. I couldn’t resist finding out how an installed compiler can still be short of what a simple C program needs.
The payoff is a C program that compiles and runs instead of stopping at the include line. The package you choose shapes which build tools are available alongside GCC.
GCC, g++, and build-essential on Ubuntu and Debian
GCC, the GNU Compiler Collection, turns source files into programs through compiler drivers. APT, the Advanced Package Tool, installs Ubuntu and Debian packages, where gcc selects C compilation and g++ selects C++.
Build-essential is a meta-package, which means APT installs a set of packages through its dependencies. It brings in gcc and g++, make, and development files such as the C library headers, so it is the practical starting package when you plan to build ordinary C or C++ projects.
| Package or command | What it gives you | Choose it when |
|---|---|---|
| gcc | C compiler driver | You need the C compiler without the broader build tool set |
| g++ | C++ compiler driver | You compile C++ source files |
| build-essential | gcc, g++, make, and common development dependencies | You need a general C/C++ build environment |
Ubuntu and Debian select compiler packages from the APT repositories configured for each release, as the Ubuntu GCC guide and Debian package FAQ explain. Check the output on your system.
Check GCC and APT before installation
Check both compiler commands first. A version line means that command is already available, so skip installing that driver and move to a sample build.
gcc --version
g++ --version
If Bash prints “command not found,” the matching compiler is missing from the shell’s command search path. This screenshot shows that state for gcc.

- Use an Ubuntu or Debian system with its APT repositories configured.
- Have sudo access, or sign in as root, because installing packages changes system files.
- Keep an internet connection available if APT needs to download the compiler packages.
Install GCC with APT
APT reads package indexes for the repositories configured on your system, so refresh them before installing if APT cannot find a package name.
1. Refresh the package indexes
sudo apt update
This updates APT’s package information. It does not install or upgrade the compiler packages.
2. Install the build tools
sudo apt install build-essential
APT may ask you to confirm the packages and disk space before it proceeds. Read that list, then accept it if it matches the development tools you want.

For a C-only setup, install gcc instead. Add g++ if you need the C++ compiler, or use build-essential when you also need make and common development headers.
sudo apt install gcc
3. Confirm the installed compiler
gcc --version
g++ --version
make --version
I ran gcc –version on Ubuntu 24.04. The output here is one example, because each release selects its own package version.

Compile and run a C or C++ program
A successful version check confirms the command exists, but a compile-and-run check also exercises the compiler and its build path through the linker. Save this C program as hello.c, then use its output to confirm the executable runs.
#include <stdio.h>
int main(void) {
puts("GCC is ready");
return 0;
}
Compile the source and run the executable. The && operator runs the second command only when the compiler returns success.
gcc -Wall -Wextra -std=c17 hello.c -o hello && ./hello
I built the C17 file with warnings enabled, then ran the executable. It printed “GCC is ready.”

Save the C++ sample as hello.cpp, then compile it with g++, which selects C++ compilation and links the standard library.
#include <iostream>
int main() {
std::cout << "g++ is ready\n";
return 0;
}
g++ -Wall -Wextra -std=c++20 hello.cpp -o hello-cpp && ./hello-cpp
I built the C++ sample with g++ and ran its executable, which printed “g++ is ready.” For a longer terminal exercise, follow our guide to build and run C or C++ programs from a terminal.

| Command result | What it confirms |
|---|---|
| GCC is ready | The C compiler produced and ran the executable |
| g++ is ready | The C++ compiler produced and ran the executable |
The warning options in these commands come from GCC, so our guide to useful GCC flags explains what they change. Our tutorial on how to run C programs in Linux takes the sample further.
Fix missing packages or headers
The error text points to different causes. Match it before changing repositories or reinstalling compiler packages.
| Message | Likely cause | Next action |
|---|---|---|
| gcc: command not found | The C compiler is absent or outside the shell’s command search path | Install build-essential, then run gcc –version again |
| Unable to locate package build-essential | APT indexes or configured repository sources do not include the package | Run sudo apt update and check your APT sources |
| fatal error: stdio.h: No such file or directory | The C library development headers are missing | Install build-essential or libc6-dev |
If APT still cannot find build-essential after its index refresh, check the repository entries for your Ubuntu or Debian release. Our APT package-not-found troubleshooting guide covers source-list checks.
C library development files supply stdio.h. Ubuntu’s build-essential package depends on libc6-dev, and our guide to installing stdio.h on Linux covers that header separately.
A compiler does not install project dependencies
Build-essential supplies a general compiler toolchain, but a project can still depend on libraries that are specific to that project. When its build instructions include a Makefile, check that make is available before following them.
make --version
A missing project header calls for that library’s development package. Installing GCC again will not supply a dependency that the project’s build files ask for.
GCC installation questions
Will APT install the newest GCC release?
APT installs the compiler version selected by your distribution release and configured repositories, so it can differ from the newest upstream GCC release.
Does build-essential create a Makefile for my project?
No. Build-essential installs the make utility. Each project supplies its own Makefile and build instructions when it uses make.
