Apple - File Not Found Error while including bits/stdc++.h

Since, bits/stdc++ is a GNU GCC extension, whereas OSX uses the clang compiler.

You have to create bits directory inside /usr/local/include and then make a header file stdc++.h inside bits and paste the contents of this code inside it. Then, it should compile as expected.


Here are the steps that I followed, if someone is still looking for an answer.

  • brew install gcc
  • gcc --version
  • cd to InstalledDir path:
    1. cd /Library/Developer/CommandLineTools/usr/bin
    2. cd ../include
  • create bits directory in there. use sudo if permission issues
    1. sudo mkdir bits
  • copy stdc++.h link in bits directory, in my case I downloaded it in Downloads.
    1. cd bits
    2. sudo cp ~/Downloads/stdc++.h stdc++.h

This was enough for the compiling.


The file is distributed with GCC. You install GCC with Macports or Homebrew.

brew install gcc