为什么没有找到静态库头文件? [英] Why are static library headers not found?

查看:651
本文介绍了为什么没有找到静态库头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用克林特哈里斯的教程设置代码在项目之间共享,并且一切都像我的电脑上预期的那样工作。但是在我的同事的机器上,似乎编译器在构建时没有从静态库项目中找到头文件。



我的同事得到了我的项目通过克隆一个git存储库。我们已经完成了所有相关的构建标志和XCode设置n次,但是该项目拒绝在他的机器上编译。



这就是我问我的同事主要是从教程中复制和粘贴:


  1. 确保项目目录的完整路径中没有空格。
  2. 在项目目录中创建另一个名为build_output的文件夹。
  3. 在XCode中的XCode> Preferences下,选择Building选项卡并将放置构建项目设置为自定义位置并指定您创建的公共构建目录的路径。
  4. 将放置中间构建文件设置为构建产品。

  5. 选择源树选项卡并通过单击+按钮并填写列来创建新的源树变量。在设置名称和显示名称中,输入
    [创建静态库的共享项目的名称]。在路径中,您将完整路径置于框架文件夹中。

执行这些步骤后,使用静态库的项目应编译他的机器和我的一样。但事实并非如此。基本上,他得到的错误是:

  error:TheFrameworkHeader.h:没有这样的文件或目录

然后是由缺少的标题引起的其他错误。



任何解决这个问题的策略?或者谁有类似的经历,可以分享一些辛苦的知识?我总结的指示中有什么遗漏?编译静态库时,是否需要在复制头文件构建阶段中设置头文件的角色?解析方案

尽管提供了一些有用的建议,我从来没有想过这一点,但这里有一些关于类似情况的人的信息。我通过将原始项目分成两部分来创建图书馆和相关项目。起初,图书馆和应用程序只是同一个项目中的两个目标。后来,我将应用程序移至一个单独的项目。一切似乎都奏效,我将两个项目都推送到远程git存储库。然而,当它们被克隆在其他计算机上时,找不到库头。



后来,我发现当我在原始计算机上克隆项目时发生同样的错误。经过很多努力,我把它固定在一个可怕的细节上:依赖项目文件夹的名称!(即,应用程序的项目,而不是库)。 .xcodeproject包,而不是应用程序标识符,但包含包含文件夹的名称。只要我改变这一切,一切正常。如果我将其更改回原始名称(在任何计算机上),则再次找不到标题。



编辑:由于我发布了这个,同样的问题发生在另一个项目中,再次,只是重命名包含.xcodeproject文件夹的文件夹修复了问题。


I've used Clint Harris' tutorial to set up code sharing between projects, and everything works just as expected on my computer. But on my co-worker's machine, it seems the compiler doesn't find the header file from the static library project when he builds.

My co-worker got my project by cloning a git repository. We've gone through all relevant build flags and XCode settings n times, but the project simply refuses to compile on his machine.

This is what I asked my co-worker to do, mostly copied and pasted from the tutorial:

  1. Make sure there is NO blank space in the complete path to the projects' directory.
  2. Inside the projects directory, create another folder called "build_output".
  3. In XCode, under "XCode > Preferences" choose the "Building" tab and set "Place Build Projects in" to "Customized location" and specify the path to the common build directory you created.
  4. Set "Place Intermediate Build Files in" to "With build products."
  5. Choose the "Source Trees" tab and create a new Source Tree variable by clicking on the "+" button and filling in the columns. In both "Setting Name" and "Display Name", put [the name of the shared project which created the static library]. In path, you put the full path to the framework folder.

Following these steps, the project that uses the static library should compile the same on his machine as on mine. But it doesn't. Basically, the error he gets is:

error: TheFrameworkHeader.h: No such file or directory

and then a string of other errors caused by the missing header.

Any strategies for trouble-shooting this? Or anyone who had a similar experience and could share some hard-earned knowledge? Is anything missing from the instructions I've summarized? Do I need to set the roles of headers in the Copy Headers build phase when compiling a static library?

解决方案

Despite some helpful advice, I never figured this one out, but here's a little info for anyone in a similar situation. I created the library and dependent project by splitting an original project into two. At first, the library and application were just two targets within the same project. Later, I moved the app to a separate project. Everything seemed to work, and I pushed both projects to remote git repositories. When these were cloned on other computers, however, the library headers were not found.

Later, I discover that the same error occurred when I cloned the projects on the original computer. After a lot of struggle, I pinned it down to one scary detail: the name of the dependent project's folder! (That is, the project with the application, not the library.) Not the name of the .xcodeproject package, not the application identifier, but the name of the containing folder. As soon as I change that, everything works. If I change it back to the original name (on any computer), again the headers are not found.

If anyone has any insight on this, please post an answer!

EDIT: Since I posted this, the same problem occured with another project, and again, merely renaming the folder that contains the .xcodeproject folder fixed the problem.

这篇关于为什么没有找到静态库头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆