Mac 我的 "stdio.h" 在哪里?
Where is my "stdio.h" in Mac?
我知道 Mac OS X 是一个基于 Unix 的系统。而且我听说stdio.h等C标准库位于/usr/local/include
或/usr/include
。但是这个目录中没有任何类型的库。我使用终端搜索这个目录,我也使用像 find ./ -iname "stdio.h"
这样的命令,但什么也没有出来。然而,奇怪的是,gcc -test.c -o test
命令有效。这是怎么发生的?我想知道我的 C 库在哪里。
p.s 我也用 Xcode。跟这个申请有关系吗?帮我!
我有 AWS EC2 linux 服务器,它有我上面引用的两个库。
如果您有 Xcode 但尚未安装可选的命令行工具包,则可能无法在通常的位置找到标准包含和库。尝试:
$ find /Applications/Xcode.app -name stdio.h
你可能会看到类似这样的内容:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h
但是,如果您打算进行任何non-Xcode(即命令行)编程,您可能需要安装命令行工具包。然后您将在 /usr/include
和 /usr/lib
.
中看到通常的 headers 和库
在我的笔记本电脑中,它出现在许多地方,例如 /usr/include/stdio.h
、/usr/include/sys/stdio.h
和 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
。
文件夹中
Applications/Xcode/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
或类似。
create/update /usr/include
的符号链接以检测库:
sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /usr/include
以上路径搜索stdio.h
即可
find /Applications/Xcode.app -path '*/usr/include/stdio.h'
我必须在每次 XCode/MacOS SDK 更新时执行此操作,今天面对 XCode 7 升级。
安装命令行工具后,无法使用 xcode-select
重新安装它们,因此可能无法使用 Mac AppStore 升级来更新路径。
卸载并重新安装 XCode,然后 运行 xcode-select --install
可能会更新路径,但有点矫枉过正。
有些帖子也提到了xcode-select --switch /Application/Xcode.app
,但我运气不太好。
如果您没有安装命令行工具,您可以运行:
xcode-select --install
将打开一个对话框,供您接受许可协议等。
(以上回复中遗漏了这一点。)
如果您已经建立了定位数据库,您可以使用
locate stdio.h
如果您还没有,请构建它。 locate
命令is awesome!
根本原因是缺少/usr/include文件夹,安装command-line工具有时不会自动添加。
安装包在
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
我已经安装了 "CommandLineTools","stdio.h" 文件存在于 Xcode 和 CommandLineTools 目录中。
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
由于 Apple 的新系统完整性保护 (SIP),当您尝试解决 creating/updating 到 /usr/include
的符号链接时,您将 运行 进入此错误
ln: /usr/include: Operation not permitted
不是禁用 SIP,更好的方法是在 /usr/local/include
中创建符号链接,例如
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
这适用于已经安装了 CommandLineTools 并且无法在 /usr/include
中找到 stdio.h
的人
我知道 Mac OS X 是一个基于 Unix 的系统。而且我听说stdio.h等C标准库位于/usr/local/include
或/usr/include
。但是这个目录中没有任何类型的库。我使用终端搜索这个目录,我也使用像 find ./ -iname "stdio.h"
这样的命令,但什么也没有出来。然而,奇怪的是,gcc -test.c -o test
命令有效。这是怎么发生的?我想知道我的 C 库在哪里。
p.s 我也用 Xcode。跟这个申请有关系吗?帮我!
我有 AWS EC2 linux 服务器,它有我上面引用的两个库。
如果您有 Xcode 但尚未安装可选的命令行工具包,则可能无法在通常的位置找到标准包含和库。尝试:
$ find /Applications/Xcode.app -name stdio.h
你可能会看到类似这样的内容:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h
但是,如果您打算进行任何non-Xcode(即命令行)编程,您可能需要安装命令行工具包。然后您将在 /usr/include
和 /usr/lib
.
在我的笔记本电脑中,它出现在许多地方,例如 /usr/include/stdio.h
、/usr/include/sys/stdio.h
和 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
。
文件夹中
Applications/Xcode/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
或类似。
create/update /usr/include
的符号链接以检测库:
sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /usr/include
以上路径搜索stdio.h
即可find /Applications/Xcode.app -path '*/usr/include/stdio.h'
我必须在每次 XCode/MacOS SDK 更新时执行此操作,今天面对 XCode 7 升级。
安装命令行工具后,无法使用 xcode-select
重新安装它们,因此可能无法使用 Mac AppStore 升级来更新路径。
卸载并重新安装 XCode,然后 运行 xcode-select --install
可能会更新路径,但有点矫枉过正。
有些帖子也提到了xcode-select --switch /Application/Xcode.app
,但我运气不太好。
如果您没有安装命令行工具,您可以运行:
xcode-select --install
将打开一个对话框,供您接受许可协议等。
(以上回复中遗漏了这一点。)
如果您已经建立了定位数据库,您可以使用
locate stdio.h
如果您还没有,请构建它。 locate
命令is awesome!
根本原因是缺少/usr/include文件夹,安装command-line工具有时不会自动添加。
安装包在
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
我已经安装了 "CommandLineTools","stdio.h" 文件存在于 Xcode 和 CommandLineTools 目录中。
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h
由于 Apple 的新系统完整性保护 (SIP),当您尝试解决 creating/updating 到 /usr/include
ln: /usr/include: Operation not permitted
不是禁用 SIP,更好的方法是在 /usr/local/include
中创建符号链接,例如
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
这适用于已经安装了 CommandLineTools 并且无法在 /usr/include
stdio.h
的人