MacOS Mojave中的C标头在哪里? [英] Where are the C headers in MacOS Mojave?
问题描述
Apple似乎一直在移动其工具,并且使用xcode-select --install
来安装命令行工具的旧解决方案不起作用.
It seems that Apple keeps on moving their tools around and the old solution of installing the command line tools are with using xcode-select --install
doesn't work.
在Mojave中,xcode-select
不再安装任何东西(GUI始终找不到软件包),并且命令行工具也不会将其自身安装在/usr/
或/usr/local
中.
In Mojave, xcode-select
doesn't install anything anymore (the GUI always fails to find the package) and the command line tools don't install itself in /usr/
or /usr/local
.
推荐答案
xcode-select --install
在Mojave中确实为我工作.也许您可以尝试从Mac App Store安装XCode,然后安装开发人员工具?
xcode-select --install
did work for me in Mojave. Maybe you can try installing XCode from Mac App Store, and then install developer tools?
关于标题位置,我在/Library/Developer/CommandLineTools/
中有Apples标题:
Regarding header locations, I have Apples headers in /Library/Developer/CommandLineTools/
:
$ sudo find /Library -name stdio.h
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
如果通过brew安装gcc,它将在/usr/local/
中添加标头:
And if you install gcc via brew, it will add headers in /usr/local/
:
$ sudo find /usr -name stdio.h
/usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0/tr1/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/tr1/stdio.h
/usr/local/Cellar/gcc/8.1.0/lib/gcc/8/gcc/x86_64-apple-darwin17.5.0/8.1.0/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.1.0/lib/gcc/8/gcc/x86_64-apple-darwin17.5.0/8.1.0/include-fixed/stdio.h
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/tr1/stdio.h
/usr/local/Cellar/gcc/7.3.0_1/lib/gcc/7/gcc/x86_64-apple-darwin17.3.0/7.3.0/include/ssp/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/include/c++/7.3.0/tr1/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/lib/gcc/7/gcc/x86_64-apple-darwin17.5.0/7.3.0/include/ssp/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/lib/gcc/7/gcc/x86_64-apple-darwin17.5.0/7.3.0/include-fixed/stdio.h
/usr/local/include/c++/8.2.0/tr1/stdio.h
/usr/local/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include/ssp/stdio.h
/usr/local/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h
(不是Apple的标头,而是GCC/GLIBC).
(Those are not Apple's headers, but GCC / GLIBC).
使用truss,我可以看到Apple clang在CommandLineTools/SDKs
中使用了clang:
Using dtruss I can see that Apple clang uses the one in CommandLineTools/SDKs
:
$ sudo dtruss -f sudo -u $USER clang test.c -o test 2>&1
3781/0x51d8: pread(0x3, "#include <stdio.h>\n\nint main(void)\n{\n printf(\"Hello, world\\n\");\n return 0;\n}\n\0", 0x4F, 0x0) = 79 0
3781/0x51d8: __pthread_sigmask(0x3, 0x7FFEE3A7E768, 0x7FFEE3A7E76C) = 0 0
3781/0x51d8: close(0x3) = 0 0
3781/0x51d8: __pthread_sigmask(0x3, 0x7FFEE3A7E76C, 0x0) = 0 0
3781/0x51d8: open("/usr/local/include/stdio.h\0", 0x1000000, 0x1A) = -1 Err#2
3781/0x51d8: open("/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0/include/stdio.h\0", 0x1000000, 0x48) = -1 Err#2
3781/0x51d8: open("/Library/Developer/CommandLineTools/usr/include/stdio.h\0", 0x1000000, 0x37) = -1 Err#2
3781/0x51d8: open("/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h\0", 0x1000000, 0x47) = 3 0
这篇关于MacOS Mojave中的C标头在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!