【发布时间】:2012-12-17 12:42:14
【问题描述】:
我正在尝试在 Objective-C Xcode 项目中使用 C 库。
库目录结构如下:
-- include/
|-- config.h
|-- lib/
| |-- file1.h
| |-- file2.h
| |-- file3.h
库的文档说包括 file1.h,而 file1.h 包括 file2.h 和 file3.h。
我收到包含 file2.h 和 file3.h` 的“找不到文件”错误。 它们由 file1.h 以下列方式包含:
#include <lib/file1.h>
#include <lib/file2.h>
我读到here,这些尖括号指示预处理器沿着 INCLUDE 环境变量指定的路径搜索包含文件,而不是在与包含#include 的文件相同的目录中搜索。
所以我在 Xcode 中添加了 INCLUDE 环境变量,方法是转到 Product->Edit Scheme.. 并将其设置为 /the-whole-path-to/include/ 但是,我仍然收到文件未找到错误。
如果我将 file1.h 更改为像这样包含它们,则这些文件将成功包含:
#include "file2.h"
但我不想对库中的每个文件都这样做。
我该如何解决这个问题?
【问题讨论】:
-
另见Xcode Build Setting Reference Apple 开发者。
标签: c xcode include environment-variables