Блог пользователя skyscraper

Автор skyscraper, история, 6 лет назад, По-английски

I was trying to figure out how to include bits/stdc++.h on macos since it uses clang, So once i found the solution i thought of creating a clear video about how to do it.

Video Link : here

  • Проголосовать: нравится
  • +26
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For me this only works in Xcode. It still doesn't compile in CLion or in the terminal.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Tbh, it's not worth using bits/stdc++.h. If you type out only the headers you need (with an autocomplete for standard headers maybe), you'll lose some seconds, but on the other hand, you'll save seconds of compilation time because the compiler won't have to go through all the headers on your system and figure out which declarations you need and which ones can be optimised out. When you need to debug and aren't slow at debugging, waiting 2 more seconds for each recompilation can be quite a waste.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

this video help me to solve the same problem, you can change clang to g++ if you like

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

First open finder. Then press shift+cmd+G.

Then copy this /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ and paste it in the box. then click Go.

When you're in v1 folder create a new folder called bits after that create a new file called stdc++.h

Then go to this page: https://github.com/tekfyl/bits-stdc-.h-for-mac/blob/master/stdc%2B%2B.h copy the content and paste it in stdc++.h file and save it.

And that's it.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Well, I find it necessary to install GCC. With GCC there is also pbds, _Find_first, etc... It’s frustrating for me to be unable to use GCC features on my Mac.

»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

I use mac and the following includes do the trick almost all the time (atleast till problem D)

headers
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I was face a same problem with it. after search couple of hour to fix the ‘bits/stdc++.h’ file not found error

Write a simple tutorial how to fix in macOs and windows fix in ‘bits/stdc++.h’ file not found here is the tutorial link. hope this will help

TUTORIAL

If you have more suggestions please tell me I will add

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For Xcode 13 or later do this :

  1. In finder, press Cmd+Shift+G

  2. Paste : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

  3. Create a new folder "bits" here

  4. Download the file or create "stc++.h" and paste the content from: https://gist.github.com/frankchen0130/9ac562b55fa7e03689bca30d0e52b0e5

»
4 года назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

For those who don't still have a problem including the file on macOS

  1. go to finder
  2. type command+shit+g
  3. paste this /usr/local/include
  4. create a folder named bits
  5. paste bits/stdc++.h inside of it
  6. restart your editor

I hope this helps.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

Step 1: Install linux.

Marinush

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Even this video didn't helped me out in order to solve the problem, I am still getting the same error. Should I also have to check other things to work this out?

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Run g++-12 instead of regular g++. Regular g++ is clang which doesnot have bits/stdc++. g++-12.

    user@home-MacBook-Pro ~ % g++ --version
    Apple clang version 14.0.0 (clang-1400.0.29.202)
    Target: x86_64-apple-darwin22.1.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

    The below one is the g++ compiler you need to use(below one is without clang).

    user@home-MacBook-Pro ~ % g++-12 --version
    g++-12 (Homebrew GCC 12.2.0) 12.2.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Note, g++-12 automatically has bits/stdc++ so you just need to switch the compiler only. No need to copy extra files.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Use Homebrew’s real GNU g++ (not Apple’s Clang) Even if you installed “gcc” via Homebrew, macOS aliases /usr/bin/g++ → Apple Clang. Check what you’re using:

g++ --version

If it says Apple clang, you’re not using GNU’s g++.

Run:

brew install gcc

Then check:

brew list gcc

You’ll see something like g++-14 (version may vary).

Now compile explicitly with:

g++-14 -std=c++17 your_file.cpp -o your_file