如何使用“用户标头搜索路径”使 Xcode 正确找到标头?
我正在尝试使用 Xcode 从 libFLAC 构建一个框架,以便在我自己的 Mac OS X 应用程序中使用。
我使用这些 FLAC 源:
http://sourceforge.net/projects/flac/files/flac-src/flac-1.2.1-src/flac-1.2.1.tar.gz/download
我只需要一个这些源文件很少,但我宁愿保持所有内容不变,这样如果我想用我自己的源代码分发框架项目,我就可以保留原始的 FLAC 源代码。
flac-1.2.1.tar.gz 包含以下目录:
flac-1.2.1/include/
flac-1.2.1/src/libFLAC/
flac-1.2.1/src/libFLAC/include/
为了构建 libFLAC,我已将“flac-1.2.1/src/libFLAC”中的 .c 文件添加到项目中(作为参考)。我还添加了 .h 文件。
源代码中使用的标头位于:
flac-1.2.1/include/FLAC/
flac-1.2.1/include/share/
flac-1.2.1/src/libFLAC/private/
例如,标头的源代码调用是:
#include "private/bitmath.h"
#include "FLAC/assert.h"
#include "private/bitwriter.h"
#include "private/crc.h"
#include "share/alloc.h"
等。
在 Xcode 中,我已将这些“用户标头搜索路径”添加到目标构建设置中:
$(SRCROOT)/flac-1.2.1/include/
$(SRCROOT)/flac-1.2.1/src/libFLAC/include/
当然,我已将我的 flac-1.2.1 目录放在正确的位置。
当我想编译时,编译器找不到头文件。我尝试使用 GCC 4.2 和 LLVM 编译器 2.0。我做错了什么?我应该做更多的事情吗?
我是在我的全 ObjC 项目中导入 C 源代码的新手,我很乐意尝试您向我提供的任何内容。只是请避免回答“如果你做不到,你就不应该这样做”。我需要学习这个并且我会的。
I'm trying to build a framework from libFLAC with Xcode, to use within my own Mac OS X application.
I use these FLAC sources:
http://sourceforge.net/projects/flac/files/flac-src/flac-1.2.1-src/flac-1.2.1.tar.gz/download
I only need a few of these source files but I'd rather keep everything untouched so I'm able to keep the original FLAC source if I want to I distribute the framework project with my own sources.
The flac-1.2.1.tar.gz contains these directories:
flac-1.2.1/include/
flac-1.2.1/src/libFLAC/
flac-1.2.1/src/libFLAC/include/
In order to build libFLAC, I've added the .c files from 'flac-1.2.1/src/libFLAC' into the project (as references). I also added the .h files.
The headers used in the source code are located in:
flac-1.2.1/include/FLAC/
flac-1.2.1/include/share/
flac-1.2.1/src/libFLAC/private/
For instance the sources code calls for the header are:
#include "private/bitmath.h"
#include "FLAC/assert.h"
#include "private/bitwriter.h"
#include "private/crc.h"
#include "share/alloc.h"
etc.
In Xcode, I've added these 'User Header Search Paths' to the the target Build Settings:
$(SRCROOT)/flac-1.2.1/include/
$(SRCROOT)/flac-1.2.1/src/libFLAC/include/
And of course, I've placed my flac-1.2.1 directory in the right place.
When I want to compile, the compiler doesn't find the headers file. I tried with GCC 4.2 and LLVM compiler 2.0. What am I doing wrong? Should I do something more?
I'm new into importing C sources in my otherwise all-ObjC project and I'd be happy to try whatever you throw at me. Just please avoid answering "If you can't do it, you shouldn't do it". I need to learn this and I will.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我有答案了,这真的很愚蠢。我的 Xcode 项目文件夹路径本身包含空格字符。编译器不喜欢这样;)
Ok I have the answer, it was really dumb. My Xcode Project folder path itself was containing a space character. The compiler doesn't like that ;)