Mac + xcode 6.4 - 头文件包含路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31440170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mac + xcode 6.4 - header include path
提问by Zgragselus
So, I have an Xcode project that contains sources which include headers from external library (static one)
所以,我有一个 Xcode 项目,其中包含来自外部库(静态库)的头文件的源代码
The include is done in common way:
包含以常见方式完成:
#include <iostream>
#include <string>
#include <jsapi.h>
The third line causes compiler error: 'jsapi.h' file not found
第三行导致编译器错误: 'jsapi.h' file not found
E.g.: Lexical or Preprocessor issue 'jsapi.h' file not found
例如: Lexical or Preprocessor issue 'jsapi.h' file not found
Now I got that I should add include folder into the project settings. So I opened the projects and into Search Paths
category under Header Search Paths
I've added /usr/local/include/
where the headers really are. Still same error. I tried copying them under /Users/.../include/
and pointing there - still same error.
现在我知道我应该将包含文件夹添加到项目设置中。所以我打开了项目并Search Paths
在Header Search Paths
我添加/usr/local/include/
了标题的真正位置下的类别中进行了分类。还是一样的错误。我尝试将它们复制到下面/Users/.../include/
并指向那里 - 仍然是同样的错误。
So I tried going through SO and people suggested using User Header Search Paths
, did that - still same error.
所以我尝试通过 SO,人们建议使用User Header Search Paths
,这样做 - 仍然是同样的错误。
Now I know this will be something really dumb, but why Xcode does not search those paths on default (assuming that /
means root folder - as for some reason my C headers are under ./Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/
). I could try copying those header files in there, but well ... that just makes more harm than good.
现在我知道这将是一件非常愚蠢的事情,但是为什么 Xcode 默认不搜索这些路径(假设这/
意味着根文件夹 - 因为某种原因我的 C 头文件在 下./Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/
)。我可以尝试将这些头文件复制到那里,但是……这弊大于利。
采纳答案by Laurent Michel
Just to show....
只是为了展示......
The "build tab" is called "Report Navigator". I circled it...
“构建选项卡”称为“报告导航器”。我圈出来了...
Then you can see the icon to the far right of:
然后您可以看到最右侧的图标:
Click that button and you will see the text of the build command in its full glory.
单击该按钮,您将看到完整的构建命令文本。
Finally, in the option, you can see below that I have the setting defined for a 3rd party library:
最后,在选项中,您可以在下面看到我为 3rd 方库定义了设置:
You can even see that I used the "User Header Search Paths" in this case. BTW, I also added the library search path (just above).
在这种情况下,您甚至可以看到我使用了“用户标题搜索路径”。顺便说一句,我还添加了库搜索路径(就在上面)。
Hope that helps!
希望有帮助!