bits/stdc++.h File Not Found | Fix It On Any Compiler

The “bits/stdc++.h file not found” error shows your C++ toolchain can’t see GCC’s all-in-one header, so you’ll need standard headers or a GCC/Clang setup.

You’ll usually hit this error at compile time, right after your #include lines are read. The code below those includes might be fine. The build still stops because the compiler can’t locate a header file you requested.

is a convenience header that comes from GCC’s libstdc++ headers. It pulls in a large set of standard library headers in one shot. That’s handy in competitive programming, where typing a long list of includes is busywork. It is not part of the ISO C++ standard, so plenty of toolchains never ship it.

If you only need a fix, replace the header now, then circle back to toolchain setup later.

This guide shows what’s going on, how to confirm the real cause in two minutes, and the clean fixes that work on Windows, macOS, Linux, and online judges. You’ll also see a safer include pattern you can paste into projects that must build everywhere.

Why This Header Works On Some Systems Only

When you write #include , you’re asking the compiler to search its configured include paths for a file named bits/stdc++.h. That file lives inside GCC’s libstdc++ header tree on many Linux installs, plus some MinGW builds on Windows.

Clang can also compile code that uses it, as long as Clang is paired with libstdc++ headers that contain the file. Clang by itself does not guarantee that header exists. Microsoft’s compiler (MSVC) uses a different standard library and a different header layout, so it won’t ship this GCC-only convenience header.

That’s why two people can compile the same file and get opposite results. One machine is using GCC with libstdc++. The other is using MSVC, or Clang paired with libc++ on macOS, or a slim toolchain install missing the extra headers.

If you’re building for a contest site that uses GCC, you can keep the shortcut. If you’re building a local app, a university assignment, or a repo meant for teammates, swapping the include is often the fastest path to a clean build on every setup.

Two-Minute Checks Before You Change Anything

Before you reinstall tools, confirm what compiler is really running. A lot of “mystery” cases happen when an editor points at a different compiler than the one you installed yesterday.

  1. Print the compiler version — Run g++ --version, clang++ --version, or cl in the same terminal your editor uses.
  2. Confirm the build command — Turn on verbose output in your IDE or build tool so you can see the exact compile line being executed.
  3. Search for the header file — On Linux or macOS, run locate bits/stdc++.h after updating the locate database. On Windows, use your toolchain folder search.
  4. List include paths — With GCC, try g++ -E -x c++ - -v < NUL (Windows) or g++ -E -x c++ - -v < /dev/null (Linux/macOS) to print the include search list.

If the include paths don’t contain a libstdc++ header folder, the header can’t be found. If the paths do contain it, but the file isn’t present, you likely have an incomplete toolchain install.

bits/stdc++.h File Not Found In Visual Studio And VS Code

If you see bits/stdc++.h file not found on Windows, the first question is which compiler you’re using. Visual Studio’s default C++ compiler is MSVC. It does not include GCC’s libstdc++ headers, so it does not include this convenience file.

VS Code is a text editor with extensions. It can drive MSVC, MinGW-w64 GCC, Clang, or WSL. That flexibility is great, yet it also makes misconfiguration easy. Fixing the error comes down to choosing one of two paths: switch to standard headers, or build with a toolchain that ships the header.

Use standard headers for the cleanest cross-platform build

If your code needs to compile on MSVC, stop including . Replace it with the specific headers you use. This works in Visual Studio, VS Code, CLion, Xcode, and online judges. It also makes builds faster to debug because you can see what you’re relying on.

  • Start with common headers — Add , , , , and , then add more only when the compiler asks.
  • Keep includes close to usage — If a file only uses unordered_map, include there instead of relying on a giant umbrella include.
  • Let the compiler teach you — Build once, read the first missing-type error, add the header for that type, and repeat until the list is complete.

Install a GCC toolchain if you need the shortcut

If you’re doing competitive programming and you like the shortcut, install a GCC toolchain that includes libstdc++ headers. On Windows, the usual options are MinGW-w64 and MSYS2. After install, confirm that g++ is the compiler VS Code is calling, not cl.exe.

  1. Install MSYS2 or MinGW-w64 — Use the installer that matches your system and pick the 64-bit toolchain.
  2. Add the bin folder to PATH — The folder that contains g++.exe must be discoverable from your terminal.
  3. Point VS Code tasks to g++ — In tasks.json, set the command to g++ and pass your standard flags.
  4. Restart the editor — VS Code reads PATH on launch in many setups, so a restart avoids stale settings.

If your GCC install still can’t find the header, search the toolchain include folder for bits. Some lightweight packages omit extra header trees. Installing the full C++ package set usually fixes that.

Use WSL when you want Linux-like tooling on Windows

WSL gives you a Linux user space where g++ and libstdc++ headers behave like they do on a typical Ubuntu install. If your assignment or repo assumes GCC, WSL can be the least fussy route. Build inside WSL, then run your executable from the WSL terminal.

Pick A Fix That Matches Your Goal

If you’re writing portable C++ that should compile under MSVC, the clean choice is to remove the GCC-only include. If you’re practicing contest code and you want the shortcut locally, install a GCC-based toolchain and point your editor to it.

  1. Swap to standard headers — Replace #include with the specific headers you use, like , , , and .
  2. Use MinGW-w64 GCC — Install a MinGW-w64 distribution, verify g++ is in your PATH, then set VS Code’s compiler path to that g++.exe.
  3. Use WSL — Install Windows Subsystem for Linux, install g++ inside your Linux distro, then build from the WSL terminal so you’re using the Linux toolchain.
  4. Use Clang with libstdc++ — If you prefer Clang, install Clang and also install GCC’s libstdc++ headers, then make sure Clang is configured to use them.

Common VS Code Misfires

Most “it still can’t find it” reports come from VS Code invoking a different compiler than the one you tested in a terminal. Your terminal might be using MinGW g++, while the build task uses MSVC, or the other way around.

  • Check your selected kit — In the CMake Tools extension, confirm the active kit points to the compiler you expect, not an older one on your machine.
  • Inspect tasks.json — If you’re using a custom build task, check the command field and the full path to the compiler binary.
  • Verify the active terminal — In VS Code, open a new terminal after changing PATH so it picks up the updated toolchain.
  • Rebuild IntelliSense data — In C/C++ extension settings, set the compiler path and then reset IntelliSense so header search matches the compiler.

If you’re in Visual Studio (the full IDE), it’s simpler: you’re building with MSVC unless you created a project that targets Clang or a GCC toolset. In that case, the portable fix is still the same: include the standard headers you use.

Portable Replacement For Competitive Programming Templates

For code that must compile across GCC, Clang, and MSVC, replace the GCC-only convenience header with the standard headers your file uses.

Start with a small core, then add what you need.

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

How To Convert A File Fast

You don’t need to guess every header by hand. Compile once, read the first error, add the header for the missing type or function, then compile again. After a few rounds you’ll have the exact list your file needs.

  1. Remove the shortcut include — Delete the #include line.
  2. Add the obvious basics — Start with , , , and .
  3. Compile and read the first error — Focus on the first missing symbol, not the cascade that follows.
  4. Add one header at a time — Keep changes small so you know what fixed what.
  5. Stop when the build is clean — Save the include list as a template for your next file.

Troubleshooting Table And Final Checklist

When you’re stuck, map what you see to the likely cause. Then apply a fix that matches your toolchain. The table below covers the cases that show up most often.

Where You See It Likely Cause Fix That Usually Works
Visual Studio project build MSVC toolset with no libstdc++ headers Replace the shortcut include with standard headers
VS Code build task Task points to a different compiler than your terminal Set the compiler path in tasks or the C++ extension
Clang on macOS Clang paired with libc++ header tree Use standard headers, or install GCC headers and target them
MinGW GCC on Windows Toolchain install missing extra header folders Install a full MinGW-w64 build that includes libstdc++ headers
Online judge submission Judge uses a different compiler than you expect Check the judge compiler page, then match your local toolchain

If you’re still seeing bits/stdc++.h file not found after switching compilers, the include paths are your next stop. A compiler can exist on your machine and still be invisible to your editor’s build task.

  1. Confirm the active compiler — Run the compiler version command from the same terminal session you build in.
  2. Print the include search list — Use the verbose preprocessor trick to see exactly where headers are searched.
  3. Fix PATH or tool settings — Make sure the editor points at the compiler you want, not the first one it finds.
  4. Prefer standard headers in shared code — That avoids toolchain-specific headers and keeps builds predictable.
  5. Rebuild from a clean state — Clear your build folder so you’re not reading old error messages from stale objects.

Once your build is clean, save the compiler path and flags. That note saves time when the same error shows up again.