fahadkabir123's blog

By fahadkabir123, history, 3 months ago, In English

I recently upgraded to macOS 13 (Ventura) public, and updated brew and gcc, but later I found this error and now I am unable to run any c++ code with gcc g++-11: warning: could not understand version '13.00.00'

ld: -rpath can only be used when targeting Mac OS X 10.5 or later collect2: error: ld returned 1 exit status [Finished in 660ms with exit code 1]

Previously i used to run my c++ code with this sublime build.

{ "cmd" : ["g++-10 $file_name -o $file_base_name && gtimeout 4s ./$file_base_name<inputf.in>outputf.in"], "selector" : "source.c", "shell": true, "working_dir" : "$file_path" }

source : https://github.com/luvk1412/Competitive-Programming/blob/master/C%2B%2B14_os_x.sublime-build

but currently is not working. Now i'm facing this problem below.

/bin/sh: g++-10: command not found [Finished in 18ms with exit code 127] [cmd: ['g++-10 map_practice.cpp -o map_practice && gtimeout 4s ./map_practice<inputf.in>outputf.in']]

I've already installed gcc-12 through Homebrew. What can i do now. Please Help me.

 
 
 
 
  • Vote: I like it
  • +7
  • Vote: I do not like it

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by fahadkabir123 (previous revision, new revision, compare).

  • »
    »
    3 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    was your issue resolved I m also facing the same issue after updating the mac

    • »
      »
      »
      3 months ago, # ^ |
      Rev. 5   Vote: I like it 0 Vote: I do not like it
      1. First of all install Command Line Tools for Xcode 14.1 beta 3. You can restart your Mac once (but worked for me without the restart). link — https://developer.apple.com/download/all/?q=xcode

      2. Then create a stdc++.h file in bits folder in this location - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/bits/

      and paste the element from this link in stdc++.h file https://gist.github.com/Einstrasse/ac0fe7d7450621a39364ed3b05cacd11 -

      1. (If you use sublime text & use this types of build system ) Then just change g++-12 (or g++-10 whatever you're using) to clang++ in your build

      i use this sublime build -

      {
           "cmd" : ["clang++ -std=c++17 $file_name -o $file_base_name && gtimeout 4s 
           ./$file_base_name<input.in>output.in"], 
           "selector" : "source.c, source.cpp",
           "shell": true,
           "working_dir" : "$file_path"
        }

      Otherwise google how to change g++-10/g++-12 to clang++ compiler. :)

      1. then if yoy find an error - fatal error: 'cstdalign' file not found

      2. Comment the line 55 in your stdc++.h file and save it.

      I hope now it will work properly.

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Have you tried g++-12?

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    YES.

    But when i run this command [ gcc-12 -v ] on terminal it shows-

    Using built-in specs. COLLECT_GCC=gcc-12 COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin22/12/lto-wrapper Target: aarch64-apple-darwin22 Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-12 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 12.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin22 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Homebrew GCC 12.2.0)

    but when i use this command [ gcc --version ]

    it shows-

    gcc: warning: could not understand version '13.00.00' gcc (Homebrew GCC 11.3.0) 11.3.0 Copyright (C) 2021 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 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I'm not sure but I think you aliased your gcc to something else before, which after the update cannot be found on the system.
      What you can do to run your code is, in your sublime build change g++-10 to g++-12

      • »
        »
        »
        »
        3 months ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        I wrote a simple hello world program (sublime build changed g++-10 to g++-12)

        but it shows-

        In file included from /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/aarch64-apple-darwin22/bits/stdc++.h:33, from map_practice.cpp:2: /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/cassert:44:10: fatal error: assert.h: No such file or directory 44 | #include <assert.h> | ^~~~~~~~~~ compilation terminated. [Finished in 98ms with exit code 1]

        • »
          »
          »
          »
          »
          3 months ago, # ^ |
          Rev. 2   Vote: I like it 0 Vote: I do not like it

          This is the same issue I'm facing right now (even I updated to Ventura yesterday and before everything used to work) but I did not find anything helpful yet.

          Currently, I'm using clang++, but it does not have bits/stdc++.h, so you have to manually add it to the directory (btw I'm still facing some issues in it, but hopefully you won't, so try atleast).

          Steps to add bits/stdc++.h
          • »
            »
            »
            »
            »
            »
            3 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Would you please explain a little bit about the step 1? I'm bit confused about this.how do i download? or else just copy it & make a file in my include folder?

            When i put the command of 3rd step- [cd Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/]

            i got - no such file or directory: Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/

            (I put the stdc++.h file directly in include folder)

            • »
              »
              »
              »
              »
              »
              »
              3 months ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Yeah, just make a new file in Downloads with the name stdc++.h and copy the content from the link. That would be easier.

              About 3rd step, I forgot to add a '/' before Library/... . I have edited the above comment and you can try again.

              Also let me know if this works out for you :) Good luck!

              • »
                »
                »
                »
                »
                »
                »
                »
                3 months ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                Now it is showing :)

                fatal error: 'bits/stdc++.h' file not found

                include <bits/stdc++.h>

                ^~~~~~~~~~~~~~~
                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Let's move this to Discord. I have DM'ed you.

        • »
          »
          »
          »
          »
          3 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          You need to install the XCode Command Line tools. Run xcode-select --install and follow the prompts.

          • »
            »
            »
            »
            »
            »
            3 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Would you please elborate the steps. thank you.

            • »
              »
              »
              »
              »
              »
              »
              3 months ago, # ^ |
              Rev. 2   Vote: I like it 0 Vote: I do not like it

              Post upgrade to Ventura you need to install XCode command line tools to get the primitive C Headers. Run the command I mentioned in your terminal. A dialog will appear, in which you have to agree to every prompt. The tools will get installed (takes some time with a decent internet).

              Plus make sure to delete any bits/stdc++.h that you have created as the other comment suggested. It is not necessary.

              • »
                »
                »
                »
                »
                »
                »
                »
                3 months ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                Yes Xcode Command Line tools are already installed. then?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  If its already installed then you shouldn't be getting any error. I had the same error as you, but simply installing the Command Line Tools worked for me.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Can you just run this in your terminal ? Just to check what version is installed. pkgutil --pkg-info=com.apple.pkg.CLTools_Executables Output should be something like:

                  package-id: com.apple.pkg.CLTools_Executables
                  version: 14.1.0.0.1.1663981106
                  volume: /
                  location: /
                  install-time: 1667055789
                  groups: com.apple.FindSystemFiles.pkg-group
                  
                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  package-id: com.apple.pkg.CLTools_Executables version: 14.0.0.0.1.1661618636 volume: / location: / install-time: 1666798366 groups: com.apple.FindSystemFiles.pkg-group

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  how do i get this update?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                  Rev. 2   Vote: I like it 0 Vote: I do not like it

                  Follow the steps I mentioned in this comment to get the latest beta. Since you have the tools installed your error must have resolved, but might run into a linker issue for which follow the linked comment.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  I have installed Command Line Tools for Xcode 14.1 beta 3 as you mentioned. But now it showing this -

                  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/bits/stdc++.h:55:10: fatal error: 'cstdalign' file not found

                  include

                  ^~~~~~~~~~~

                  1 error generated.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Refer to this comment fahadkabir123

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  tried this. too much error showing.

          • »
            »
            »
            »
            »
            »
            3 months ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            I've DM'ed you. I can't reply to your text.

            _biscuit

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Should i change sublime build for this problem ? if yes , would you please provide me if you currently using.

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I'm also facing an issue after upgrading my os -> 0 0x1044841a0 __assert_rtn + 140 1 0x10430ba8c mach_o::relocatable::Parser::parse(mach_o::relocatable::ParserOptions const&) + 4536 2 0x1042ddd38 mach_o::relocatable::Parser::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148 3 0x1043464ac ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468 4 0x104349360 ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56 5 0x1b44d41f4 _dispatch_client_callout2 + 20 6 0x1b44e8f8c _dispatch_apply_invoke_and_wait + 224 7 0x1b44e826c _dispatch_apply_with_attr_f + 1152 8 0x1b44e847c dispatch_apply + 108 9 0x1043491f4 ld::tool::InputFiles::InputFiles(Options&) + 616 10 0x1042cb6c0 main + 552

I don't have any idea what this is...I have googled it and people are getting this error but there seems to be no solution for this. Also this error only appears when i add this line in my code-> void _print(string t) {cerr << t <<ln;} // to debug a string ig. Also sometimes when i take map of pair as keys etc.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Same issue but only if I use std::map. Also #include <assert.h> error with g++-12. Currently I'm using clang, but it does not support auto keyword :sob:

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Just add -std=c++14 after clang++ in your build. The 'auto' warning would go away.

      • »
        »
        »
        »
        3 months ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        getting this error now /Library/Developer/CommandLineTools/usr/include/bits/stdc++.h:55:10: fatal error: 'cstdalign' file not found

        +can you send your sublime build?

        • »
          »
          »
          »
          »
          3 months ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          In your stdc++.h file, comment line 55 -> #include <cstdalign>. Then, it would work perfectly.

          Sublime Build
  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Did you really Google Search? There is an entire GitHub issue thread for the issue you mentioned. Link here.

    The gist of the long thread, in order to fix the problem, head over to this link, and install Command Line Tools for Xcode 14.1 beta 3. You can restart your Mac once (but worked for me without the restart).

    Cheers!

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hey, I am also facing similar issues. While compiling, terminal throws error : assert.h: No such file or directory

Were you able to solve your issue? What worked for you?

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Did you install gcc on your mac? I think with a mac, always just use the native clang compiler, and download bits/stdc++.h manually. That's the only realistic modification you need.

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I recently upgrade my mac air m1 to ventura and I am also facing the same problem .

Have you figured out some solution to this ?