7

I updated my system to macOS Catalina and then installed gcc-9 from homebrew, then I got the missing headers error as everybody did after updated to Mojave. But things goes different on Catalina, the macOS_SDK_headers_for_macOS_10.14.pkg does not exist. I tried to install the old version my friend send to me from his Mojave Mac, but failed because the system is too new. Then I tried to brew upgrade,brew doctor,brew cleanup,and re-installed Xcode11 and Command Line Tools through App Store and xcode-select --install. Nothing worked and my clang broke too! Here is my error log when compiling hello world program with gcc-9:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:66,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cstdlib:75,
                 from hello.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:34: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  443 | int     getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:449:39: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  449 | int     setiopolicy_np(int, int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cstdlib:75,
                 from hello.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:52:74: error: expected initializer before '__OSX_AVAILABLE_STARTING'
   52 | int   posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
      |                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cstdlib:75,
                 from hello.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:270:53: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  270 | void  arc4random_buf(void * __buf, size_t __nbytes) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:273:46: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  273 |   arc4random_uniform(uint32_t __upper_bound) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cstdlib:75,
                 from hello.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:292:45: error: expected initializer before '__OSX_AVAILABLE_BUT_DEPRECATED_MSG'
  292 | int  daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:325:6: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  325 |      __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:333:6: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  333 |      __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:79,
                 from /usr/local/Cellar/gcc/9.2.0/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/stdio.h:78,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cwchar:44,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ios:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ostream:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iostream:39,
                 from hello.cpp:2:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h:39:56: error: expected initializer before '__OSX_AVAILABLE_STARTING'
   39 | int     renameat(int, const char *, int, const char *) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
      |                                                        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cwchar:44,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ios:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ostream:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iostream:39,
                 from hello.cpp:2:
/usr/local/Cellar/gcc/9.2.0/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/stdio.h:370:67: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  370 | int dprintf(int, const char * __restrict, ...) __printflike(2, 3) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/9.2.0/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/stdio.h:371:79: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  371 | int vdprintf(int, const char * __restrict, __gnuc_va_list) __printflike(2, 0) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cwchar:44,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ios:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ostream:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iostream:39,
                 from hello.cpp:2:
/usr/local/Cellar/gcc/9.2.0/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/stdio.h:372:123: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  372 | ssize_t getdelim(char ** __restrict __linep, size_t * __restrict __linecapp, int __delimiter, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/9.2.0/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/stdio.h:373:105: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  373 | ssize_t getline(char ** __restrict __linep, size_t * __restrict __linecapp, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/cwchar:44,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ios:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/ostream:38,
                 from /usr/local/Cellar/gcc/9.2.0/include/c++/9.2.0/iostream:39,
                 from hello.cpp:2:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:197:67: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  197 | wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:198:76: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  198 | wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:199:34: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  199 | wchar_t *wcsdup(const wchar_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:200:54: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  200 | int     wcscasecmp(const wchar_t *, const wchar_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                      ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:201:65: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  201 | int     wcsncasecmp(const wchar_t *, const wchar_t *, size_t n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:202:49: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  202 | size_t  wcsnlen(const wchar_t *, size_t) __pure __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:215:47: error: expected initializer before '__OSX_AVAILABLE_STARTING'
  215 | wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~

and the error log compiling with clang:

In file included from hello.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:86:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
1 error generated.

But with Xcode IDE(GUI), everything works good. What should I do?

  • 1
    I have the same issue and until now I was not able to solve it. I use clang-9 instead (`brew install llvm`). From what I saw in brew git page it seems to be a known an unsolved yet gcc issue. – Chelmy88 Sep 28 '19 at 08:28
  • @Chelmy88 Thanks a lot, but I am deciding to downgrade to Mojave, hhhh – user10937121 Sep 28 '19 at 09:17
  • 1
    I have the similar issue on Mojave as well, btw. I can't compile fmt via conan and gcc-9.2.0 installed from brew. – Nemanja Boric Sep 29 '19 at 13:03
  • https://apple.stackexchange.com/questions/372032/usr-include-missing-on-macos-catalina-with-xcode-11 – suiwenfeng Nov 21 '22 at 07:34

0 Answers0