### Z38's blog

By Z38, history, 3 years ago, ,

Hi all,

Recently I had a talk with koosaga and he told me that unfortunately he can't use #include <bits/stdc++.h> because his operating system is OS X. I was surprised to know that because I'm using this header on OS X without any troubles.
When I explained him how I manage to do that he told me I should compose a topic about this because it will help many people :)
So I will try to cover two things in my post:
a) How to compile #include <bits/stdc++.h> in Sublime text?
b) How to compile C++11 features like lambdas, auto, etc. in Sublime text?
Let's get started.

#include<bits/stdc++.h> usage
3 easy steps.
1) Install Xcode
2) Download stdc++.h from my GitHub. The file is not mine of course, I just googled it and commented out including cstdalign library because it just wouldn't compile on my mac (I wasn't interested enough to figure out why).
3) Now you must simply put stdc++.h into /Applications/Xcode.app/Contents/Developer/Platforms/ChosenTargetPlatform/Developer/SDKs/ChosenMacOSSDK/usr/include/bits
Done!

C++11 features usage
Here you will need a custom build system for Sublime text. It's easy to create!
3 easy steps again.
1) Download gpp.sublime-build from my GitHub.
2) Go to Sublime, then select Tools->Build System->New Build System. This is the place where you should paste gpp.sublime-build. Don't forget to save the file.
3) Relaunch Sublime, from now on your new build system will be available at Tools->Build System.
Done!

I hope someone will find this helpful. Thanks for your attention! :)

•
• +85
•

 » 3 years ago, # |   +18 great post!a long long scroll of #include's bb
 » 3 years ago, # | ← Rev. 2 →   +10 Thanks for sharing! I found myself struggling with the first problem some time ago. Here's a hacky approach I used to solve it: Make a directory called "bits" and put a "stdc++.h" file in it. You can put the directory wherever you want on your Mac. Fill the header with whatever includes you might need. Add an "-I" flag while calling "clang++" command. The good thing I find about this approach is that you don't need to install XCode and you don't need to mess with its internal directories. I personally prefer command-line interface to Sublime build framework, but I believe you should be able to add this flag anyway. :) Please refer my dotfiles for more details: link.
 » 3 years ago, # |   +21 Alternatively, you can install gcc via homebrew and compile with that. The benefit of this is that you get the same compiler as the judge.
 » 3 years ago, # | ← Rev. 2 →   +3 Also you can add -D YOUR_VAR after g++ (.sublime-build) to use #ifdef YOUR_VAR freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif or something elsee.g "shell_cmd": "g++ -D DEBUG \"\${file}\"...
 » 3 years ago, # |   +8 Now I can die in peace
 » 2 years ago, # |   +1 Just install gcc6 and you will be able to use "bits/stdc++" and "ext/pb_ds". //I am using OS X
 » 15 months ago, # |   0 I followed your steps and bits/stdc++.h does work on Xcode but it doesn't work on Sublime...What may I've done wrong?
•  » » 15 months ago, # ^ |   +4 Inside the directory /usr/local/include/ create a folder named 'bits' and copy the stdc++.h file in bits folder.I did this and it worked for me.
•  » » » 15 months ago, # ^ |   +1 Yeah, I agree. It's just that simple!
•  » » » 15 months ago, # ^ |   0 It worked, thank you a lot!
•  » » » » 15 months ago, # ^ |   0 Glad to hear!
 » 15 months ago, # |   0 there is faster way by using mingw on windows,(for linux nothing) then search sublime text c++ build(there is a github post &video about it)
 » 10 months ago, # |   0 Finally found it! Thanks a ton!
 » 7 months ago, # |   0 Where to save the gpp.sublime-build file.