本文介绍了如何设置包括以x code项目路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个Objective-C X code ++项目使用C库。

I am trying to use a C library in an Objective-C Xcode project.

该库的目录结构是如下所示:

The libraries directory structure is as follows:

-- include/
    |-- config.h
    |-- lib/
    |    |-- file1.h
    |    |-- file2.h
    |    |-- file3.h

图书馆的文档说,包括file1.h和file1.h包括file2.h和file3.h。

The library's docs say to include file1.h, and file1.h includes file2.h and file3.h.

我收到未找到文件的错误了包括file2.h和file3.h`的。
它们被以下面的方式包括file1.h:

I am getting "file not found" errors for the includes of file2.h and file3.h`.They are included by file1.h in the following manner:

#include <lib/file1.h>
#include <lib/file2.h>

这里

我看了的是,这些尖括号指示在preprocessor搜索包括沿由包含环境变量指定的路径的文件,而不是在同一个目录中包含的#include文件搜索。

I read here that these angle-brackets instruct the preprocessor to search for include files along the path specified by the INCLUDE environment variable, as opposed to searching in the same directory as the file that contains the #include.

于是我加入了通过转到产品 - >编辑计划..它设置为 /包括X code ++环境变量中,全路径为/有/ 不过,我仍然得到文件中未发现的错误。

So I added the INCLUDE environment variable in Xcode by going to Product->Edit Scheme.. and set it to /the-whole-path-to/include/ however, I am still getting the file not found errors.

该文件包含成功如果我改变file1.h,包括他们是这样的:

The files are successfully included if I change file1.h to include them like this:

#include "file2.h"

但我宁愿这样做,在库中的每个文件。

but I'd rather not do that for every file in the library.

我该如何解决这个问题?

How can I fix this?

推荐答案

想通了。

所有你需要做的就是-I标志添加到您的构建下的其他C标志

All you have to do is add the -I flag to your build setting under "Other C Flags"

因此​​,在您的目标构建设置搜索其他C标志,并添加 -I /路径到包括/

So in your target's build setting search for "Other C Flags" and add -I/path-to-include/

下面是截图:

Here's a screenshot:

这篇关于如何设置包括以x code项目路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:49