When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

fahadkabir123's blog

By fahadkabir123, history, 17 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

| Write comment?
»
17 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).

  • »
    »
    17 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

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

Have you tried g++-12?

  • »
    »
    17 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.

    • »
      »
      »
      17 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

      • »
        »
        »
        »
        17 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]

        • »
          »
          »
          »
          »
          17 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
          • »
            »
            »
            »
            »
            »
            17 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)

            • »
              »
              »
              »
              »
              »
              »
              17 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!

              • »
                »
                »
                »
                »
                »
                »
                »
                17 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>

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

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

        • »
          »
          »
          »
          »
          17 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.

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

            Would you please elborate the steps. thank you.

            • »
              »
              »
              »
              »
              »
              »
              17 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.

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

                Yes Xcode Command Line tools are already installed. then?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 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
                  
                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  how do i get this update?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 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.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 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.

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

                  Refer to this comment fahadkabir123

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

            THANK YOU FOR THE HELP!

»
17 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.

  • »
    »
    17 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:

    • »
      »
      »
      17 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.

      • »
        »
        »
        »
        17 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?

        • »
          »
          »
          »
          »
          17 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