所以,苹果包括<stdlib.h>
,<stdio.h>
和朋友。你必须确保标题在路径上。你可以找到一个选择的<stdlib.h>
的使用和它们各自的路径与find
:
$ find /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer -name stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/c++/4.2.1/tr1/stdio.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/stdio.h
这里有两种方法可以确保头是在路径上。首先(首选方式)是使用--sysroot
。使用--sysroot
确保两个头和库的路径,所以你不会需要额外的编译器选项(如-I
, - L
,l
等):
CC=export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CFLAGS="-Wall -Wextra -Wconversion -arch armv7 -arch armv7s \
--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk""
然后,你会使用它像这样:
$(CC) $(CFLAGS) -c foo.c -o foo.o
第二种方法是只包括头,但你会遇到类似的痛点为库:
CC=export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CFLAGS="-Wall -Wextra -Wconversion -arch armv7 -arch armv7s \
-I="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include""
你还是会使用它,像这样:
$(CC) $(CFLAGS) -c foo.c -o foo.o
以我为例,我是用“没有这样的文件或目录”错误而失败。但它不是没有这样的文件<stdio.h>
(这是我读它是)。相反,我用键盘保存了一个文件:一个CTRL + S错过了CTRL,所以我的--sysroot
拼写错误。它使用sdks
(复数s
)而不是sdk
(单数)。所以SYSROOT目录不正确。
我开始赏金由于拼写错误....
来源
2015-01-11 01:49:32
jww
感谢您的回复,但重复的没有它的不是这个问题我检查了。 –
我不是iOS开发人员,但是如果您正在编写C++代码,您是否尝试过使用? –
Enno