My System: MacOSX 10.9 64-bit

Hey guys, I am working on Sublime Text 3. I have included the #include <bits/stdc++.h> but when I am compiling the source code,

adityas-air% g++ 285C.cpp
285C.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
1 error generated.

Is there some other header file specific to Mac that is needed to be included instead of this or some tweaking that is needed to be done to Sublime Text 3.Thanx in advance!

5 Answers 5


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

brew install gcc

  • I suppose I downloaded the developer tools for Xcode, after which I was able to compile C++ programs using g++ compiler. Oct 5, 2014 at 9:01
  • 2
    Xcode does not include gcc but llvm. You can compile C++ programs but you will not have gcc specific files.
    – Matteo
    Oct 5, 2014 at 9:02
  • Ok, So I can still install GCC with Homebrew(say) and the issue will be resolved? Oct 5, 2014 at 9:05
  • Yes but before doing that: what are you doing?
    – Matteo
    Oct 5, 2014 at 9:43
  • Actually I want this for competitive coding, including this header automatically includes all the required headers which otherwise are needed to be explicitly mentioned. Although I can have a template for that but just one header makes code look concise, just that!! Oct 5, 2014 at 11:14

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.

  • Great. Thanks!! Mar 13, 2020 at 19:54
  • 1
    I think this is the best answer. Don't know how other answer got accepted. Mar 8, 2021 at 12:07
  • I also needed to comment out some lines, namely: // #include <cstdalign> //#include <cuchar> // #include <memory_resource>
    – geekdenz
    Aug 15, 2021 at 8:19

Did this

"cmd": ["/usr/local/Cellar/gcc/6.1.0/bin/g++-6", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",

        "name": "Run",
        "cmd": ["bash", "-c", "/usr/local/Cellar/gcc/6.1.0/bin/g++-6 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]

after doing brew install gcc and it's working. The g++-6 is the version of the compiler that gets installed, it may be different for different users. Thank you!

  • 1
    g++-10 file.cpp
    – kenorb
    Oct 17, 2020 at 16:00

After steps sited by nohillside Pour cmake projects (OSX) Added this line to your CMakeLists.txt:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .