Я обновил свою систему до macOS Catalina, а затем установил gcc-9 из homebrew, после чего я получил ошибку об отсутствующих заголовках, как и все после обновления до Mojave.Но на Каталине все обстоит иначе: macOS_SDK_headers_for_macOS_10.14.pkg
не существует.Я попытался установить старую версию, которую мой друг отправил мне со своего Mac Mojave, но не удалось, потому что система слишком новая.Затем я попытался brew upgrade
, brew doctor
, brew cleanup
и переустановил Xcode11 и инструменты командной строки через App Store и xcode-select --install
.Ничего не сработало и мой лязг сломалсяВот мой журнал ошибок при компиляции программы hello world с 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);
| ^~~~~~~~~~~~~~~~~~~~~~~~
и журнал ошибок при компиляции 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.
Но с Xcode IDE (GUI) всеработает хорошо.Что мне делать?